WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post types and categories (2 posts)

  1. webcd008
    Member
    Posted 3 years ago #

    Hi I was wondering if somebody could help me.

    I've setup a custom post type (shown below)

    add_action( 'init', 'create_my_post_types' );
    
    function create_my_post_types() {
    	register_post_type( 'Products',
    		array(
    			'labels' => array(
    				'name' => __( 'Products' ),
    				'singular_name' => __( 'Product' ),
    				'add_new' => __( 'Add New Product' ),
    				'add_new_item' => __( 'Add New Product' ),
    				'edit_item' => __( 'Edit Product' )
    
    			),
    
          <strong>'rewrite' => array('slug' => '/%category%','with_front'=>false),</strong>
    
    			   'taxonomies' => array('category'),
    
    				'supports' => array('title', 'editor'),
    			'public' => true,
    		)
    	);
    }

    What I want to do is when a user select a post category on the right hand side the category slug is added to the permalink.

    I was wondering why this line is the custom post type does not work

    rewrite' => array('slug' => '/%category%','with_front'=>false),

    I'm really stuck.

    Thanks a million

  2. Joseph
    Member
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic