Title: [Plugin: Display Posts Shortcode] use $category in opener without hacking plugin?
Last modified: August 20, 2016

---

# [Plugin: Display Posts Shortcode] use $category in opener without hacking plugin?

 *  Resolved [raskull](https://wordpress.org/support/users/raskull/)
 * (@raskull)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-use-category-in-opener-without-hacking-plugin/)
 * Hi, it’s me again. I see your code for filtering the wrapper opening and close.
   However I need to get the category variable into the opening. What is the best
   way to accomplish what I want without hacking your plugin?
 * Below is my hack to your line 149, the results of which provide a link to the
   category page of the category that was specified in the shortcode `[display-posts
   category="Foo" posts_per_page="3"]` and looks like this: Foo Headlines : [More Foo](https://wordpress.org/support/topic/plugin-display-posts-shortcode-use-category-in-opener-without-hacking-plugin/?output_format=md#)
 *     ```
       $open = apply_filters( 'display_posts_shortcode_wrapper_open', '<h2>' . $category . ' Headlines : <a href="' . get_category_link( get_cat_ID( $category ) ) . '">More ' . $category . '</a></h2><' . $wrapper . ' class="display-posts-listing">' );
       ```
   
 * [http://wordpress.org/extend/plugins/display-posts-shortcode/](http://wordpress.org/extend/plugins/display-posts-shortcode/)

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

 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-use-category-in-opener-without-hacking-plugin/#post-2731282)
 * Hmm, I don’t think that can be done with the filter as it is. All the filter 
   lets you do is modify it as straight text – it doesn’t pass any of the shortcode’s
   parameters for you to work with (like category).
 * I’d need to modify the filter to pass the $atts, and then you could then pull
   the category out of that.
 *  Thread Starter [raskull](https://wordpress.org/support/users/raskull/)
 * (@raskull)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-use-category-in-opener-without-hacking-plugin/#post-2731325)
 * Well, I’ll leave it up to you whether you think that would be useful to others
   and worth your effort.
 * p.s. I do appreciate your super clean work, which even I, a novice, can recognize!

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

The topic ‘[Plugin: Display Posts Shortcode] use $category in opener without hacking
plugin?’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [raskull](https://wordpress.org/support/users/raskull/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-use-category-in-opener-without-hacking-plugin/#post-2731325)
 * Status: resolved