Title: Adding exclusions to a block
Last modified: June 18, 2020

---

# Adding exclusions to a block

 *  Resolved [Bam Bam](https://wordpress.org/support/users/bam-bam/)
 * (@bam-bam)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-exclusions-to-a-block/)
 * Hi,
 * Just discovered this plugin, great for people like me that struggle with PHP 
   and Javascript.
 * I just created a Post Grid block and I’m wondering if it is possible to hard 
   code an exclusion into it ??
 * What I want to exclude is a sticky post from the grid and display it normally
   above the grid.
 * Kindest Regards
    Bam Bam
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadding-exclusions-to-a-block%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Luke Carbis](https://wordpress.org/support/users/lukecarbis/)
 * (@lukecarbis)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-exclusions-to-a-block/#post-13001407)
 * Hi [@bam-bam](https://wordpress.org/support/users/bam-bam/). Assuming you’re 
   using WP_Query to build your posts grid, you can specify a post ID as part of
   the `post__not_in` parameter.
 * For example:
 *     ```
       $exclude = array( 42 );
       $query = new WP_Query( array( 'post__not_in' => $exclude ) );
       ```
   
 *  Thread Starter [Bam Bam](https://wordpress.org/support/users/bam-bam/)
 * (@bam-bam)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-exclusions-to-a-block/#post-13001415)
 * Thanks for the prompt reply, I’m using all of the code from one of your tutorial
   pages.
 * PHP and Javascript does my head in, just where and exactly in that query should
   I add post id ??
 * The post ID is 438.
 * Also just where should I place the code in the file ??
 * Sorry to be such a numpty, but I’m getting old and have my head around HTML and
   CSS but the rest is like Hieroglyphics to me.
    -  This reply was modified 6 years, 1 month ago by [Bam Bam](https://wordpress.org/support/users/bam-bam/).
 *  Plugin Author [Luke Carbis](https://wordpress.org/support/users/lukecarbis/)
 * (@lukecarbis)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-exclusions-to-a-block/#post-13006287)
 * Assuming your using the code from this post: [https://getblocklab.com/custom-post-grid-block-using-wp_query/](https://getblocklab.com/custom-post-grid-block-using-wp_query/)
 * Modify the part that is commented as “WP_Query Arguments” to add the exclude:
 *     ```
           // WP_Query arguments
           $args = array(
               'post_type'      => array( $post_type ),
               'posts_per_page' => $post_count,
               'post__not_in'   => array( 438 ),
           );
       ```
   
 *  Thread Starter [Bam Bam](https://wordpress.org/support/users/bam-bam/)
 * (@bam-bam)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-exclusions-to-a-block/#post-13006577)
 * Many thanks, worked a treat, I tried all sorts of things and nothing worked.
 * I did manage to hide it using some CSS but I’d rather do it this way.
 * If it’s not too much to ask, how can I now show that post we just excluded, immediately
   above the grid on it’s own, it is a Welcome post and I was trying to make it 
   prominent, it is tagged as a Sticky post if that helps.
 * Like it displays on the Blog page that is already there.
 * [https://healthut.com/blog-posts/](https://healthut.com/blog-posts/)
 * Many thanks for your help on this.
 * Kindest Regards
    Bam Bam
 *  Plugin Author [Luke Carbis](https://wordpress.org/support/users/lukecarbis/)
 * (@lukecarbis)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-exclusions-to-a-block/#post-13006588)
 * One way would be to reuse the same code again, but this time change `post__not_in`
   to `post__in`.
 *  Thread Starter [Bam Bam](https://wordpress.org/support/users/bam-bam/)
 * (@bam-bam)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-exclusions-to-a-block/#post-13006595)
 * Ok thanks I’ll give it a whirl
 *  Thread Starter [Bam Bam](https://wordpress.org/support/users/bam-bam/)
 * (@bam-bam)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-exclusions-to-a-block/#post-13006899)
 * [@lukecarbis](https://wordpress.org/support/users/lukecarbis/) Thanks for your
   help with this, but I messed about with it for ages and couldn’t get it working,
   so I just made a duplication of the original block and made a couple of changes
   to it and I got exactly what I was after.
 * Great plugin.
 * Kindest Regards
    Bam Bam

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Adding exclusions to a block’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/block-lab_5c34e8.svg)
 * [Block Lab](https://wordpress.org/plugins/block-lab/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/block-lab/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/block-lab/)
 * [Active Topics](https://wordpress.org/support/plugin/block-lab/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/block-lab/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/block-lab/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Bam Bam](https://wordpress.org/support/users/bam-bam/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/adding-exclusions-to-a-block/#post-13006899)
 * Status: resolved