Title: [Plugin: Display Posts Shortcode] not to include current ID
Last modified: August 20, 2016

---

# [Plugin: Display Posts Shortcode] not to include current ID

 *  Resolved [mgrant](https://wordpress.org/support/users/mgrant/)
 * (@mgrant)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-not-to-include-current-id/)
 * display-posts-shortcode displays the current post in a list of posts which always
   included the current post. This didn’t make sense to me, especially if you’re
   trying to display a list of other posts with the same tag within a post. Perhaps
   there should be an arg like ‘do_not_include_current_ID’ or something like that.
   However, for now, adding this to display-posts-shortcode.php fixed my problem:
 *     ```
       // If Post IDs
       	if( $id ) {
       		$posts_in = explode( ',', $id );
       		$args['post__in'] = $posts_in;
       >	} else {
       >		$args['post__not_in'] = array(get_the_ID());
       >	}
       ```
   
 * The idea was that if you didn’t specify a particular ID, then it would exclude
   the current ID. The reasoning was because you can not specify both post__in and
   post__not_in in the same set of args.
 * [http://wordpress.org/extend/plugins/display-posts-shortcode/](http://wordpress.org/extend/plugins/display-posts-shortcode/)

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

 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [14 years ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-not-to-include-current-id/#post-2535175)
 * Great idea, but it’s best to use a filter rather than modifying the plugin. Here’s
   how to do it: [http://www.billerickson.net/code/display-posts-exclude-current-post/](http://www.billerickson.net/code/display-posts-exclude-current-post/)
 *  Thread Starter [mgrant](https://wordpress.org/support/users/mgrant/)
 * (@mgrant)
 * [14 years ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-not-to-include-current-id/#post-2535176)
 * It’s true that in general it’s better to not modify a plugin. However, I’m really
   proposing this as a bug fix. As I said, the behavior as is doesn’t make sense.
 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [14 years ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-not-to-include-current-id/#post-2535177)
 * It’s not a bug since the default behavior of the plugin is to not limit any specific
   posts. But if you do want it limited in the way you describe, you can use the
   filter as outlined in the code I provided.
 *  [Kyle](https://wordpress.org/support/users/kyleguate/)
 * (@kyleguate)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-not-to-include-current-id/#post-2535204)
 * Hey Bill,
 * 2 questions:
 * 1) It seems, based on the thread above, that if I wanted to add some more exclusion
   functionality to your Display_Posts_Shortcode plugin, you would recommend that
   I use the filter you provided – right?
 * 2) I’m not sure I completely understand how to use the filter but here’s a guess–
   I need to write custom, unsupported code to do the exclusions and then stick 
   it in with your code calling your filter function. Is that right?
 *  [Kyle](https://wordpress.org/support/users/kyleguate/)
 * (@kyleguate)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-not-to-include-current-id/#post-2535205)
 * Based on a one of your comments on a different thread, I infer that the answer
   to question #2 is to stick the filter code into the functions.php file, right?
 * How would you feel if I forked the code and added my exclusion options? Would
   you pull those changes into the master?
 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-not-to-include-current-id/#post-2535207)
 * You can include your changes in your theme’s functions.php file, or write a separate
   plugin that uses the filters. That’s what makes filters and hooks so great – 
   you’re able to easily extend a plugin’s functionality without modifying the core.
 * If you think the changes you’ve made are of use to most people, you can [submit a pull request on Github](https://wordpress.org/support/topic/plugin-display-posts-shortcode-not-to-include-current-id/github.com/billerickson/Display-Posts-Shortcode?output_format=md)
   or just post the code here and I can take a look.

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

The topic ‘[Plugin: Display Posts Shortcode] not to include current ID’ is closed
to new replies.

 * ![](https://ps.w.org/display-posts-shortcode/assets/icon-256x256.jpg?rev=2940963)
 * [Display Posts - Easy lists, grids, navigation, and more](https://wordpress.org/plugins/display-posts-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/display-posts-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/display-posts-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/display-posts-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/display-posts-shortcode/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-not-to-include-current-id/#post-2535207)
 * Status: resolved