• Hello, sorry for my english because I use google translation. I would like to exclude a category from a wordpress block. I tried this: in the parameters of the block, filter, Multiple categories filter and I put “-2” which is the id of the category I want to exclude from the block. But without success.

    Thanks in advance for the help provided ??

Viewing 1 replies (of 1 total)
  • Hello, You can pass you exclude category post id in the below array which is in the $query variable.
    Below code will work for post query.

    <?php
    $query = new WP_Query( array( 'category__not_in' => array( 11 ) ) );
    ?>
    
    <?php if ( $query->have_posts() ) : ?>
        <?php while ( have_posts() ) : the_post(); ?>
            <?php
                /*You content goes here */
            ?>
        <?php endwhile; ?>
        
        <?php else : ?>
            <?php /* If you query doesn't work then this code will execute */ ?>
    <?php endif; ?>

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘exclude category from the block’ is closed to new replies.