• Resolved woody2016

    (@woody2016)


    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author Anthony Hortin

    (@ahortin)

    There’s no specific way to do this with Quark. You’d be unlikely to find any theme that has this kind of functionality built in.

    Using pre_get_posts like you are, is going to be the best way. At the moment, you’re specifically setting your condition when is_home() is true. You could try doing it on is_single() as well and see if that helps.

    Thread Starter woody2016

    (@woody2016)

    Hi Anthony,
    Thank you for your help, i have stopped researching how to achieve this.
    Your time is much appreciate!
    Nel

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Excluding posts on single post view according to category’ is closed to new replies.