Ready to get started?Download WordPress


Changing permalink of custom posts (4 posts)

  1. MikeB12
    Posted 1 year ago #

    I've tried reading up on past posts here but my head is just spinning.

    My problem is I'd like to change my permalink structure for a custom full width posts under a custom category.

    For example, my permalink structure for posts is example.com/04/2013/postname and for my custom posts I'd like the permalink structure to be example.com/categoryname/postname.

    What's the easiest way to accomplish this?

  2. hiphopinenglish
    Posted 1 year ago #

    You need to use the rewrite function when registering a CPT. See the example below from the Codex:

    add_action( 'init', 'create_post_type' );
    function create_post_type() {
    	register_post_type( 'acme_product',
    			'labels' => array(
    				'name' => __( 'Products' ),
    				'singular_name' => __( 'Product' )
    			'public' => true,
    			'has_archive' => true,
    			'rewrite' => array('slug' => 'products'),

    ^^Your slug will not be products!

  3. MikeB12
    Posted 1 year ago #

    Thanks! I should add the custom post is already created. But I want to go back into the custom post code and edit the permalink structure and make it different from the permalinks from the rest of my standard posts.

  4. hiphopinenglish
    Posted 1 year ago #

    Then my suggestion should work. Make the change, create a Post if you haven't already, view it, and see what URL is returned.

Topic Closed

This topic has been closed to new replies.

About this Topic