• Resolved Ude

    (@ude)


    Hi guys.

    Is there a quick way to rename the default post type “articles” into something else in the functions.php-file?

    Thanks!

    -Ude

Viewing 6 replies - 1 through 6 (of 6 total)
  • Do you mean the default CATEGORY for posts? If so, you don’t need to edit the functions.php. Just go to Settings–>Writing in the dashboard. You’ll see a drop down for Default Post Category.

    If your post-types are listed as Articles, that is probably due to whatever theme you are using. Let me know if it is and I can point you in the right direction

    Thread Starter Ude

    (@ude)

    Hi wspencer!

    I mean just changing the post type name itself – “article” – into another. “Article” isn’t an accurate name for the service I’m building right now.

    First I created a new post type with register_post_type() with its own name, but I’m thinking is there a way method to just rename the default post type instead of creating a new separate one.

    So you created a custom post type of “article” and just want to rename it to something else?

    Or in your theme is what is usually referred to as “post” called “article” instead?

    regardless, let’s say you want to change what is referred to as “posts” into “Products”. (you can take the code below and change it to fit whatever it is you’re changing from and to)

    function custom_detail_post_labels() {
    	global $wp_post_types;
    	$labels = &$wp_post_types['post']->labels;
    	$labels->name = 'Products';
    	$labels->singular_name = 'Product';
    	$labels->add_new = 'Add Product';
    	$labels->add_new_item = 'Add Product';
    	$labels->edit_item = 'Edit Products';
    	$labels->new_item = 'Product';
    	$labels->view_item = 'View Product';
    	$labels->search_items = 'Search Products';
    	$labels->not_found = 'No Products found';
    	$labels->not_found_in_trash = 'No Products found in Trash';
    }
    
    	add_action( 'init', 'custom_detail_post_labels' );

    Hopefully that answers your question for you. If so, please mark this topic as Resolved. Thanks!

    Thread Starter Ude

    (@ude)

    The new custom post type was my first solution for my problem (named “record/records”), but I still had the old default post type “articles” which I don’t need and will only confuse the end user.

    Therefor I’m asking can I just rename the default post type into “record/records” which is displayed in the browser (it can otherwise still be refered to as “post” in php-code).

    Thread Starter Ude

    (@ude)

    Thanks, that helped me get on the right track! I also added this piece of code too that is needed for the admin-panel (in case someone else needs this too):

    function change_post_menu_label() {
    	global $menu;
    	global $submenu;
    	$menu[5][0] = 'News';
    	$submenu['edit.php'][5][0] = 'News';
    	$submenu['edit.php'][10][0] = 'Add News';
    	$submenu['edit.php'][16][0] = 'News Tags';
    	echo '';
    }
    
    add_action( 'admin_menu', 'change_post_menu_label' );
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Modifying post name (article) into something else’ is closed to new replies.