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'm currently working on a community site for a fairly large blog (approx 500,000 uniques/month). I've decided I want to do a Network for all the different portions of the community site to keep the DB load to a minimum.

IE: - A site for a user generated recipe site - A site for a user forum (using wordpress) - A site for guest blog posts

For the recipe site I was thinking of using a custom post type called recipe. My issue with this is I'd be getting URLS like the following by default: recipes.domain.com/recipe/%post-name% or domain.com/recipes/recipe/%post-name% (depending on whether I use subdomain or subdirectory in my Network).

So for option 1 I can remove the Tags I've found the following http://www.ultimatewebtips.com/remove-slug-from-custom-post-type/ OR Wordpress 3.3 custom post type with /%postname%/ permastruct?

While this looks good I don't want to add any overhead or have to worry about things breaking when updating wordpress or using a caching plugin. I'm not saying it will, but I just figure messing with the permalink structure might not be such a good idea.

For the second option I could just use the default post type as my "recipe" (since I will not be using it for anything else). Doing so I can add a filter like the following:

add_filter( 'gettext', 'change_post_to_recipe' );
add_filter( 'ngettext', 'change_post_to_recipe' );

function change_post_to_recipe( $translated ) 
{  
    $translated = str_replace( 'Post', 'Recipe', $translated );
    $translated = str_replace( 'post', 'Recipe', $translated );
    return $translated;
}

And then use the remove_post_type_support() to remove things I don't need such as 'editor' and 'excerpt'.

My only worry with this is that the functions gettext or ngettext would get loaded a ton, and I'd be doing an excessive amount of str_replace. The benefit of using the default post type is that I can use all the default built in functions to do what I need, and chances are most plugins would work fine with this.

Any suggestions would be appreciated.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

The main issue with the rewrites is clashes, not maintainability, since that code would have worked in 3.1 and 3.4 and is unlikely to break, and if it did there'd be deprecated notices for a few versions.

I would suggest using renamed posts, but instead use code like this:

function change_post_menu_label() {
    global $menu;
    global $submenu;
    $menu[5][0] = 'Recipes';
    $submenu['edit.php'][5][0] = 'Recipes';
    $submenu['edit.php'][10][0] = 'Add Recipes';
    $submenu['edit.php'][16][0] = 'Recipe Tags';
    echo '';
}
function change_post_object_label() {
    global $wp_post_types;
    $labels = &$wp_post_types['post']->labels;
    $labels->name = 'Recipes';
    $labels->singular_name = 'Recipe';
    $labels->add_new = 'Add Recipe';
    $labels->add_new_item = 'Add Recipe';
    $labels->edit_item = 'Edit Recipe';
    $labels->new_item = 'Recipes';
    $labels->view_item = 'View Recipes';
    $labels->search_items = 'Search Recipes';
    $labels->not_found = 'No Recipes found';
    $labels->not_found_in_trash = 'No Recipes found in Trash';
}
add_action( 'init', 'change_post_object_label' );
add_action( 'admin_menu', 'change_post_menu_label' );
share|improve this answer
    
Ahh this is a much better way of renaming the default post type. Thank you. –  SgtSlaughter Aug 20 '12 at 14:35
    
Nifty ^_^ if this works well for you, feel free to mark it as the answer ( use the tick/mark underneath the up/down vote counter ) –  Tom J Nowell Aug 20 '12 at 15:12
add comment

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.