• Posts arent doing what I need, so i am making a CPT that basically work like Posts, but with some tweaks to it. The problem is that i cant seem to get the Permalinks to work like they should for posts. I am trying to do %taxonomy%/blog/%category%/%postname%/

    This is my code:

    add_action( 'init', 'register_cpt_blog' );
    
    function register_cpt_blog() {
    
        $labels = array(
            'name' => _x( 'Blog', 'blog' ),
            'singular_name' => _x( 'Post', 'blog' ),
            'add_new' => _x( 'Add New', 'blog' ),
            'add_new_item' => _x( 'Add New Post', 'blog' ),
            'edit_item' => _x( 'Edit Post', 'blog' ),
            'new_item' => _x( 'New Post', 'blog' ),
            'view_item' => _x( 'View Post', 'blog' ),
            'search_items' => _x( 'Search Posts', 'blog' ),
            'not_found' => _x( 'No posts found', 'blog' ),
            'not_found_in_trash' => _x( 'No posts found in Trash', 'blog' ),
            'parent_item_colon' => _x( 'Parent Post:', 'blog' ),
            'menu_name' => _x( 'Blog', 'blog' ),
        );
    
        $args = array(
            'labels' => $labels,
            'hierarchical' => false,
    
            'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'trackbacks', 'comments', 'revisions' ),
            'taxonomies' => array( 'category', 'post_tag', 'campus' ),
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'menu_position' => 5,
    
            'show_in_nav_menus' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => false,
            'has_archive' => true,
            'query_var' => true,
            'can_export' => true,
            'rewrite' => array('slug' => '%campus%/blog/'),
            'capability_type' => 'post'
        );
    
        register_post_type( 'blog', $args );
    }

    Any suggestions on how i can get that permalink structure to work? Right now i just get: /%campus%/blog/postname/. I filter the campus part, which is great, but not sure how to solve my category issue. Thoughts?

  • The topic ‘custom post types (cloned posts)’ is closed to new replies.