admin管理员组

文章数量:1194125

I created a review website recently where I write website and product reviews.I intend to write blog posts too on my website. I don't want to create subdomain or separate blog page.Both review posts and blog should be on same website.But problem is both blog posts and reviews are mixed up in categories. For example a blog post on "How to start affiliate marketing" is a blog post and "Clickbank or Shareasale review " is review post.Both lies in same category named "Affiliate marketing"

How can I differentiate these posts so when user click on blog from menu only blog posts show up and when click review only review posts should show. I have mentioned categories as submenu too in both blog and review link too

I created a review website recently where I write website and product reviews.I intend to write blog posts too on my website. I don't want to create subdomain or separate blog page.Both review posts and blog should be on same website.But problem is both blog posts and reviews are mixed up in categories. For example a blog post on "How to start affiliate marketing" is a blog post and "Clickbank or Shareasale review " is review post.Both lies in same category named "Affiliate marketing"

How can I differentiate these posts so when user click on blog from menu only blog posts show up and when click review only review posts should show. I have mentioned categories as submenu too in both blog and review link too

Share Improve this question edited Jul 21, 2022 at 9:31 Hamza Jameel asked Jul 21, 2022 at 9:31 Hamza JameelHamza Jameel 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Sounds like you're sharing the default category taxonomy for both of your post types. When you want separate categories per post type, you would need to create a custom taxonomy for your review posts.

Please check out the register_taxonomy function in the WordPress developers documentation. https://developer.wordpress.org/reference/functions/register_taxonomy/

See below an example of a custom taxonomy.

add_action( 'init', 'my_review_cat_init', 0 );
function my_review_cat_init() {
 
    $labels = array(
        'name'                  => '',
        'singular_name'         => '',
        'search_items'          => '',
        'all_items'             => '',
        'parent_item'           => '',
        'parent_item_colon'     => '',
        'edit_item'             => '',
        'update_item'           => '',
        'add_new_item'          => '',
        'new_item_name'         => '',
        'menu_name'             => '',
    );

    register_taxonomy( 'review_cat', array('review'), array(
        'hierarchical'          => true,
        'public'                => true,
        'labels'                => $labels,
        'show_ui'               => true,
        'show_admin_column'     => true,
        'meta_box_cb'           => true,
        'query_var'             => true,
        'publicly_queryable'    => true,
        'public'                => true,
        'rewrite'               => array('with_front' => false),
    ));

}

本文标签: postsSeparate blog and reviews categories