• Resolved schungx

    (@schungx)


    Currently there is no way to style a listing item based on its post type (because I suppose it is assumed that only ONE post type is ever queried or returned). This is a dangerous assumption because any plugin may modify the query parameters to return more than one post type in a query.

    Therefore, it will be very useful to have classes on the listing items to distinguish different post types. For example:

    class=”post-type-post post-id-123 post-published”
    class=”post-type-portfolio post-id-457 post-draft”

    and I suppose this will be extremely easy to add.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter schungx

    (@schungx)

    After more research on this, I suppose this will be easy to do by writing a custom filter to modify the output, so it is not absolutely necessary to have this functionality built-in.

    However, built-in functionality will be much better than requiring everybody to write custom filters… I believe every website designer needs a way to style the items.

    Plugin Author Bill Erickson

    (@billerickson)

    While I do see how that would be helpful, the majority of this plugin’s users are not styling the output based on post type.

    I believe we would cause more issues by adding additional classes, especially generic ones like you have specified (ex: post-type-portfolio) as it’s likely those classes will already be used somewhere in a site, and Display Posts Shortcode would then inherit whatever styling was meant for another element with that class.

    You can currently specify a “wrapper_class” which is applied to the entire listing, and you can use the “display_posts_shortcode_post_class” filter to add classes on each individual listing item.

    Add this code to your theme’s functions.php file (or a core functionality plugin) for your post type classes to automatically be added: https://gist.github.com/billerickson/709ba8f168f7f7d7896592b43e476295

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

The topic ‘Suggestion: make class from post type’ is closed to new replies.