• Resolved Jason Judge

    (@judgej)


    This is a great tag for selecting posts of all types. However, so far as I can see, it just displays a listing, i.e. titles, maybe an image.

    Is there any way to throw each post that is selected, at a custom template? For example, I have different post types that I need to pass through different summary templates, because they are, well, different post types and each need their own special handling.

    Is this possible? I certainly hope so ??

    — Jason

    https://www.ads-software.com/extend/plugins/display-posts-shortcode/

Viewing 4 replies - 1 through 4 (of 4 total)
  • I dig this idea too. What’s the simplest implementation of it? How would it work for you?

    Plugin Author Bill Erickson

    (@billerickson)

    Are you asking if different uses of the shortcode (querying different types of content) can be displayed in different ways?

    First, you have a quite a few display options in the shortcode itself, like include_date, include_excerpt…

    But there’s also an output filter you can use to customize the actual output. For instance, if you’re listing upcoming events, you might want to include the event date and location. Use the ‘display_posts_shortcode_output’ filter to modify what is output. Example: https://www.billerickson.net/code/display-posts-shortcode-additional-fields/

    You could add your own attributes to the shortcode and use that to determine how it is customized in the output filter. For instance, [display-posts template=”event”]. In your output filter, check if ( isset( $atts[‘template’] ) && ‘event’ == $atts[‘template’] ), then do whatever customizations you’d like to it.

    Is that what you were looking for, or something else?

    Thread Starter Jason Judge

    (@judgej)

    Yes, that looks spot-on. So that I understand it correctly, so long as that filter returns *something*, then that return content will replace the entire summary for that post?

    The way I want to use it, is to display products from a WooCommerce shop. To do that, we have a function we can call up to display a single product, which uses customised formatting (through templates) so we would not want any of the output generated by this plugin. If that is how this filter works, then that is exactly what we are looking for.

    — Jason

    Plugin Author Bill Erickson

    (@billerickson)

    Yes, that’s exactly how it works. You’re able to filter the entire output of the post listing.

    You’re also able to customize the outer wrapper. By default it is a ul (and the listings are li’s). This can be changed to an ol or div.

    [display-posts wrapper=”div”]

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Template’ is closed to new replies.