Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I hate to try to reinvent the wheel here, but none of the suggested post seem to work in answering my question. I am building a system for our 30 Under 30 honorees, which is basically setup as a portfolio of images. The types of post I am creating will be called "honorees", and the overall menu called "30 Under 30". The portfolio page that they are all displayed on, will be http://domain.com/30under30/ But for some reason the posts are created as http://domain.com/honoree/%honoree-name%/

How do I change the my taxonomy follow menu name, as opposed to post type name? The labels section of my code from functions.php is below

   function project_custom_init()  
{  
  $labels = array(  
    'name' => _x('Honorees', 'post type general name'),  
    'singular_name' => _x('Honoree', 'post type singular name'),  
    'add_new' => _x('Add New', 'honoree'),  
    'add_new_item' => __('Add New Honoree'),  
    'edit_item' => __('Edit Honoree'),  
    'new_item' => __('New Honoree'),  
    'view_item' => __('View Honoree'),  
    'search_items' => __('Search Honorees'),  
    'not_found' =>  __('No honorees found'),  
    'not_found_in_trash' => __('No honorees found in Trash'),  
    'parent_item_colon' => '',  
    'menu_name' => '30 Under 30'  
  );  
 $args = array(  
    'labels' => $labels,  
    'public' => true,  
    'publicly_queryable' => true,  
    'show_ui' => true,  
    'show_in_menu' => true,  
    'query_var' => true,  
    'rewrite' => true,  
    'capability_type' => 'post',  
    'has_archive' => true,  
    'hierarchical' => false,  
    'menu_position' => null,  
    'supports' => array('title','editor','author','thumbnail','excerpt','comments')  
  );  
  // The following is the main step where we register the post.  
  register_post_type('honoree',$args);  
  // Initialize New Taxonomy Labels  
  $labels = array(  
    'name' => _x( 'Tags', 'taxonomy general name' ),  
    'singular_name' => _x( 'Tag', 'taxonomy singular name' ),  
    'search_items' =>  __( 'Search Types' ),  
    'all_items' => __( 'All Tags' ),  
    'parent_item' => __( 'Parent Tag' ),  
    'parent_item_colon' => __( 'Parent Tag:' ),  
    'edit_item' => __( 'Edit Tags' ),  
    'update_item' => __( 'Update Tag' ),  
    'add_new_item' => __( 'Add New Tag' ),  
    'new_item_name' => __( 'New Tag Name' ),  
  );  
    // Custom taxonomy for Honoree Tags  
    register_taxonomy('tagportfolio',array('honoree'), array(  
    'hierarchical' => true,  
    'labels' => $labels,  
    'show_ui' => true,  
    'query_var' => true,  
    'rewrite' => array( 'slug' => 'tag-portfolio' ),  
  ));  

Any help would be appreciated. I'm trying my best to understand the code as I figure this out.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Your post_type slug will default to the name of the post_type unless specified otherwise. So, in it's most basic form you can set a custom base slug as follows,

'rewrite' => array( 'slug' => 'slug-name-here');

Currently, you have it set to true only.

Don't forget to visit your permalinks page in the dashboard to flush your rewrite rules after you make your changes to get the new base rule to work!

Also take a look at,

http://codex.wordpress.org/Function_Reference/register_post_type

Which contains a great deal of information about the parameters associated with custom post types, including the initial rewrite rule. You can do some advanced things to meet numerous scenarios with rewrite rules, but for the most basic of requirements you can rely on the above suggested snippet.

I'd provide more examples, but I'm writing from a phone...

Good luck!

share|improve this answer
    
userabuser you are a genius! Thank you so much. Turns out I was editing the wrong re-write. Thanks for pointing me in the right direction. –  sacobserver Oct 21 '12 at 4:55
    
@sacobserver No problem, if there's nothing else you need help with concerning this matter then don't forget to mark this question and best of luck with the rest of your theming :) –  userabuser Oct 21 '12 at 5:34

You cannot have a custom post type page with the permalink format you want. This format is reserved for Pages (I mean WP native "Page" post type).

UPDATE : This answer is wrong, see comments for details.

The better way to achieve the result you want is to create a page named 30Under30, which will have the http://domain.com/30under30/ permalink, and then create a custom page template that will display the custom post type list.

In the honoree.php file, put the following code (comments with "Template Name" keyword is not optional):

<?php /* Template Name: Honoree */
    query_posts(array('post_type' => 'honoree'));

    // loop to display honoree posts
    while(have_posts()): the_post();

    endwhile;
?>

Then select it in the "Page Template" menu of your 30Under30 page.

share|improve this answer
1  
Yes you can... That's what the rewrite declaration is for. It can be different than the name of your post_type, but when not specified, or in the case where you return true as in the case of the OP above, it will only return the given name honorees. Try specifying a custom slug, visit your permalinks page in dashboard (to flush rewrite rules) then visit your new slug domain.com/slug and like magic... it works. Also you don't need to create a page in the dashboard because the 'has_archive' => true parameter enables the archive templates, so you can do archive-honorees.php etc –  userabuser Oct 20 '12 at 8:01
    
Thanks for your comment userabuser. I would not have understand my error by only reading your perfectly right answer. That the way I like stackoverflow : you can still learn something when you reply to others questions. –  Fabien Quatravaux Oct 21 '12 at 20:06
    
Question to the stack overflow advanced users : do I need to delete my wrong answer ? –  Fabien Quatravaux Oct 21 '12 at 20:07
1  
Short answer is no. The reason for this is because often, even incorrect answers can provide a benefit in educating readers, by adding context and depth to the overall question, showing what not to do in contrast to what you should be doing. On some occasions, you might add an incorrect answer, realize so, then remove it before anyone ever responds or down-votes, or you may even replace its contents with an update. That's ok. We all offer up incorrect answers from time to time, I'm no different. No one will judge you otherwise, so long as we all learn, that's all that matters. –  userabuser Oct 22 '12 at 8:57
1  
...and for the record, not to pick on you, but you shouldn't use query_posts, instead you should use the much more reliable WP_Query to setup and handle your query parameters (there are valid reasons as to why we do this which extend beyond what I can write in comments here). Overall though, respect goes to any and all users who are willing to contribute answers, right or wrong. That's what this site is about. –  userabuser Oct 22 '12 at 8:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.