Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 67836

Tags and categories question

$
0
0

Replies: 0

Hello i got help about a month ago with a problem with tags and catregories not working. However i now want to add another custom post called ‘food’ and everything works except the tags and categories again.

How do i change the code so it my tags and categories will work for the other post as well? i can only get one of them to work at the same time.
Here is the old thread
https://wordpress.org/support/topic/tags-and-categories-not-working-on-custom-post-2/
@bcworkz

function enable_category($query) {
  if ( !is_admin() && $query->is_main_query() ) {
    if ($query->is_category()) {
      $query->set('post_type', array( 'post', 'review' ) );
    }
  }
}

function enable_tags($query) {
  if ( !is_admin() && $query->is_main_query() ) {
    if ($query->is_tag()) {
      $query->set('post_type', array( 'post', 'review' ) );
    }
  }
}

add_action('pre_get_posts','enable_category');
add_action('pre_get_posts','enable_tags');

Viewing all articles
Browse latest Browse all 67836

Trending Articles