Custom Post Type links not working - wordpress

I'm wanting to make an employee page populated from a custom post type called "Employees". It lists http://www.domain.com/employees/joe/ as the permalink but the the actual page shows up as unavailable. Am I missing something on the taxonomy side?
Thanks in advance!

Answering it because I just figured it out, but after quite a bit of googling, nothing came up, so hopefully this helps somebody.
Reset the permalinks!
For some reason, if you create a custom post type after you initially set your permalink structure, it needs to be reset. Go to your settings/permalinks, set them to default, save, and then set them back how you want, save, and you're good to go.

The permalink structure needs resetting because this regenerates the rewrite rules within wordpress, allowing the different URL segment structures to be properly recognised and processed.
Wordpress rewriting works very well, but getting around it for custom post types, custom taxonomies etc. has added an extra set of needs to the system, which are slowly being improved. The custom rewrite system was added, and it's continued development is gradually making it easier to tackle issues like this.
In many cases, a custom taxonomy is the easiest way to go.

Related

alter content administration page (admin/content)

I'm working on some drupal installation and googled the whole day, but I can't figure out an answer to the following question:
How is it possible to alter the admin/content page in a way that specific roles are only able to see or filter out limited content types?
Please notice that I don't want to restrict node access in general, I just want to make this page less confusing for editors with different roles and tasks.
I know there is the administration views module and there I can set filter fields in the way I want. The problem with this is that I'm not able to enter the views access restrictions and so all I can do is limit the view's content types for all roles.
Can somebody give me a hint how to solve this?
Thank you very much and sorry for bad english.
One way would be to make a custom module.
In this module you would create a page with hook_menu().
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7
Then in the page callback function that you create you load global $user and switch between the $user->roles, out putting different HTML lists of links depending on their role. If you want something a little more dynamic you can always load the various content types with node_type_get_types().
Then go into structure -> menus -> navigation and disable the default link, replacing it with the new page you created.
If you aren't 100% clear on how to do a couple of these things comment here and I will update my answer.

Set the permalink to any domain in Wordpress

Is this possible to achieve without too much effort or a plugin? It's simply to instantly redirect to a site I've made in my portfolio if the post doesn't have any content.
Note that I don't want a script in the actual post to redirect since I only use Wordpress as the backend and fetch all the data to be used by a JavaScript backbone app.
EDIT : Added some extra info in a comment
Short Answer: No. You cannot set your Post Permalink to an external asset without directly editing the database.
Long Answer: First off, you need to understand the purpose of the Permalink. It isn't just an arbitrary link to somewhere. It's reserved specifically for storing where that specific post lives within the context of your Wordpress installation.
Your post doesn't live on example.com. It has its own ID, and Wordpress has a specific spot set aside for it where it can be seen on YOUR domain. Leave it as such.
Instead, what you should be doing is employing the tools Wordpress gives you to achieve what you want. A Plugin doesn't exist for what you want because - quite frankly - it's a fairly trivial task when approached CORRECTLY and doesn't warrant the use of an external resource.
So what's the correct way?
Use a Custom Field. Name your Custom Field something like 'externalHref' and fill that in with your link to the website you want to point to in case there's no post content.
Then in whatever templates you're using to generate your posts, just check either for the existence of your Custom Field called 'externalHref' or check for the non-existence of Post Content. In either case, instead of generating a link using The Permalink you can simply build a link that points to wherever you need.

wp email publishing with custom content type?

having researched wp forums and only found people asking this question without any answers, I resort to the source of all truth (stack overflow).
I use wordpress custom post types (Custom Post Type UI plugin) and find it very handy.
Now, I want to be able to email-publish some content via WPs built-in email publishing system, but by default that is set up to only publish as regular posts.
I am aware that I can choose categories for the emailed content, but I would very much like to keep all the pages and content of my news (=blogposts) feeds the way they are, being able to put the email-published content into a content type of its own would really help me out.
So I wonder if anyone has done that, and how you would go about it. Thanks for any input.
Not sure if this helps people looking for a solution, but I managed to do it like this...
When a post is submitted for publish by WordPress default email2post, there is an action hook named 'publish_phone' running, so you can get the post there and change its type like this:
add_action('publish_phone','custom_type_by_mail');
function custom_type_by_mail($post_id){
$p = get_post($post_id,'ARRAY_A');
$p['post_type'] = "my-custom-type";
wp_update_post($p);
}
I resorted to converting it into a post category instead of its own content type. I know not whether there be any other solution =)

Organising Custom Content for Wordpress

I am already very confused as I am typing this thread out. Please forgive me if my query is a little too difficult to understand.
I have an existing Real Estate Site that I intend to move 100% into WordPress. The existing site has one backend for listings and another blog section for reviews.
You can probably see why I have decided to make the move to a full WordPress powered site. Maintaining both ends of the site is both tedious & cumbersome.
I have read and understood Custom Post Types & Custom Taxonomies and how they work. I am rather excited about implementing them. However there is some content I am finding difficult to organise.
* An existing database table of about 4,000 Condominium Projects
Each entry in the Condominiums table has some "bio-data" like Year Completed, No. of Units, Facilities, Amenities etc.
Currently each listing in my site has an ajax query that fetches information from this table on demand.
In the new site, I intend to have a link to the respective condominium in each property listing.
This link should display information about the specific condo and display 'results' of matching listings.
Also, some condos have long article reviews done for them. In my current site, these reviews are displayed in the blog section. Separated altogether.
So here's my question.
How would I connect everything together. A duplicate perhaps? Taxonomy & Post for each condo? That will mean over 3,000 unique entries. Wouldn't that be an "overkill"?
If it is a taxonomy, the link will probably display all posts (listings) that have that condo name. But it wouldn't link to an actual page of either it's review or bio-data.
Any thoughts will be very much appreciated... Please feel free to ask if I have missed out any vital information!
Thanks in advance
The seems very straightforward to me and a perfect fit for WordPress (and I shudder to think of doing anything in Drupal you don't have too; and this from someone who developed in Drupal for 2+ years...)
Anyway:
Each condo gets stored in a custom post type.
All the "bio-data" gets stored in a custom field. Alternately you could create a taxonomy called "bio-data" and have a term value for each of the options but this won't work well for things like "SqFt" unless you do ranges (i.e. 1200sft-1300sqft) because terms can only be used for "true/false" attributes (i.e. either it applies or it doesn't) and not for specifics like exact offer prices, etc.
The long articles can just be stored in the "content" section of the condo post type (unless you have multiple per condo then you can either store in comments as #Jan Fabry suggested or you can create a custom post type "review")
Like I said this is really straightforward. Of course I've lived and breathed database apps for 20+ years so it comes second nature to me. Any questions, just ask...
This was how I managed to solve my own question!, Ironically enough, MikeSchinkel had an almost identical answer, so I accepted his answer instead.. So here's what I have:
A Custom Post Type for Condominiums labelled 'Reviews' in the admin section. The property 'Bio-data' is in custom fields. This Custom Post Type has a rewrite rule:
array( 'slug' => 'condominium' );
That way, I managed to have each Permalink to show something like:
http://domain.com/condominium/post-title
I have added a page called Condominiums and had it set to use a custom template - which basically shows the latest posts of condominiums with reviews. I also intend to extend the template for it to show a Search Condominiums function.
Added relevant taxonomies that can be searchable - like Brands & Developers.
I have already converted previous reviews to this. The last thing I will have to do will be to post all the Condominiums from the condominiums database to the wp_posts table using this Custom Post Type.
This is the part I am crossing my fingers for as I will have to see if the rewrite rules are going to significantly slow down my site as this will be 4,000 entries. This issue has been recently brought to my attention here
http://core.trac.wordpress.org/ticket/12935
I will update this thread once I have completed the importing - since this is the only place I have posted a question and have it answered - if anyone might be interested!
Thank you for your suggestions. I hope this helps someone else who is in a similar predicament.
Would it work if you view the Condominiums as posts, and the reviews as comments to these posts? This would keep them together, and is conceptually not even too far from the original intention. You can put the extra information in custom fields and tags (which gives you free searching capabilities). Then you should see for yourself if you still need to create a custom post type, or just do it with regular posts (why not?).
But yes, you are stretching the original WordPress concept a little. Drupal or some other CMS might be a better option, and have more plugins that are suited to your situation.

WordPress Post Date Changes On Update

I have my permalinks in WordPress set to the Month and Name setting. This generates URLs like /blog/2009/09/my-post-name. Every time a post is updated, it changes the posting date, which can potentially change the permalink address.
This is wreaking some havoc on my site, as I'll have banner/button ads throughout that point to the permalink. When a post from August is updated in September, all of the ads become broken links until I discover this and change it.
Is there any way to make the original posting date stay static, despite any updates? I'm looking for something like a plug-in or an overlooked setting, as I have multiple authors with varying degrees of computer literacy.
Thanks for any help!
Cory
Update:
Apparantly this is behaviour that others aren't experiencing, so I'm attaching a screen shot of exactly what's happening. Top image is before saving, bottom image is after saving.
(source: opl.on.ca)
Are you sure updating a post changes the permalink? I don't have this behaviour in my installations. What do changes a permalink is changing the post date.
In database, acoording to this schema, we have post__date and post__modified, two different attributes: used in create an update action. If you're having your post-date modified without modifying it directly
Updating a post date in Wordpress http://img18.imageshack.us/img18/3440/wordpresspostdate.png
then I'm afraid some plugin may be changing it's value.
Reading your description, I'm assuming you're using static links to your banners. Try to use a simple plugin that creates these links based on your post id: some simple routine would do it. You can get some information using get_post for example.
<?php
$my_id = 7;
$post_id_7 = get_post($my_id, ARRAY_A);
$slug = $post_id_7['post_name'];
?>
... or even easier with get_permalink. You need just your post id.
<?php
echo get_permalink(7);
?>
So, at least if your permalinks are changing without a reason and you dont know how to fix them, at least you can build them dinamically.
Just read the codex documentation and Function Reference to see what's avaiable to make your life easier!
I run the same permalink settings and don't have trouble with post updates changing the permalink. There are separate editor settings for the permalink and a user has to specifically change the permalink from that editor, which is right under the post title in the text editing box in the post editor. That's a WP thing to keep permalinks from getting broken all the time.
Maybe you should try using a few static pages? That way you can have both a clean permalink: mysite.com/mypermalink/ that won't change, if in fact your post permalinks are changing from a plugin that you need to use.

Resources