WordPress.org

Forums

Changing permalink of custom posts (4 posts)

  1. MikeB12
    Member
    Posted 2 years 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. J M
    Member
    Posted 2 years 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',
    		array(
    			'labels' => array(
    				'name' => __( 'Products' ),
    				'singular_name' => __( 'Product' )
    			),
    			'public' => true,
    			'has_archive' => true,
    			'rewrite' => array('slug' => 'products'),
    		)
    	);
    }

    ^^Your slug will not be products!

  3. MikeB12
    Member
    Posted 2 years 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. J M
    Member
    Posted 2 years 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