Excluding posts on single post view according to category
-
Hello Anthony,
Please could you help / advise me, it would be very much appreciated?
I have a requirement for CMS using posts, the user can not have page editing rights. So far achieving this using a post category and displaying on the page by category query.
Any posts in this category need to be excluded from the main blog view and single post view.
I have a function:
/** Exclude Specific Categories From The WordPress Loop */
add_action( ‘pre_get_posts’, ‘exclude_specific_cats’ );
function exclude_specific_cats( $wp_query ) {
if( !is_admin() && is_main_query() && is_home() ) {
$wp_query->set( ‘cat’, ‘-4’ );
}
}It removes posts in the category from the main blog but posts in the category can still be viewed in single post view using the rel nav previous/next. I’ve also tried editing the single.php file and excluding by post ID’s without success.
Have you any advice please, or is there a better way of achieving this with Quark?
Kind regards and thank you as always.
Nel
- The topic ‘Excluding posts on single post view according to category’ is closed to new replies.