WordPress.org

Ready to get started?Download WordPress

Forums

Display Posts Shortcode
[resolved] Add option to use ordered list or no list (17 posts)

  1. daymobrew
    Member
    Posted 2 years ago #

    After making use of the filter to control the shortcode output, I thought about an enhancement to allow people specify the list type.

    Currently it produces an unordered list. How about an ordered (numbered) list? How about no list at all (use divs)?

    I write some code to do this and pasted a patch to http://pastebin.com/jwT8EzNu
    The commented out $output line should be removed. I replaced it with a sprintf as I felt it was easier to read.

    I added a post counter and included this as an id e.g. post-2. I didn't use a class because it could conflict with the class in the body tag.

    http://wordpress.org/extend/plugins/display-posts-shortcode/

  2. daymobrew
    Member
    Posted 2 years ago #

    Another thing, as I initialise the $container to 'ul' and $post_container to 'li' before checking $list_type, the ul/unordered/unordered_list/default parts of switch() aren't needed. I put them in for completeness.

  3. Bill Erickson
    Member
    Plugin Author

    Posted 2 years ago #

    While it's definitely a useful feature, the plugin is more focused on querying posts than on display. I purposefully gave it a very simple display and then added the filter so that you could customize the presentation.

    But you bring up a good point. The filter I provided let's you modify the markup of the individual posts but not their wrapper. How about I create another filter for the outer markup?

  4. daymobrew
    Member
    Posted 2 years ago #

    I think that filters are appropriate to developers and shortcode attributes for non-developers.

    To keep both camps handy you could provide both.

  5. williambennettiv
    Member
    Posted 2 years ago #

    This would be a great addition (IMO) as I would love to be able to stylize the posts as well as the wrapper! Currently I'd use just a div, but want some stylization...Orrr if I use some stylization everything gets indented as a list, which is undesirable in my application

    Thanks! Greattttt plugin!

  6. Bill Erickson
    Member
    Plugin Author

    Posted 2 years ago #

    You can actually control this now using the 'wrapper' attribute.

    [display-posts wrapper="div"]

    That will use a div for the outer wrapper (around all posts) and divs around each individual posts.

    You can customize these further using the inner and outer output filters:

    display_posts_shortcode_output
    display_posts_shortcode_wrapper_open
    display_posts_shortcode_wrapper_close
  7. williambennettiv
    Member
    Posted 2 years ago #

    Thank's for such a quick reply on this Bill! I kept tinkering last night trying different things here & there...and by the time I came across the output/open/close my eyes were burnt out. Are these also going in the shortcode or the css?

    ultimate goal is to have posts listed as a div, but still be able to stylize them, mainly to pad above & below.

    mucho thanks!

  8. daymobrew
    Member
    Posted 2 years ago #

    You can easily style the default (more modified) output by adding padding to the li (or div) elements.

  9. williambennettiv
    Member
    Posted 2 years ago #

    thanks for adding extra guidance daymobrew! I think I am confusing myself with adding the attributes to the shortcode or modifying the filters in the plugin. My end-goal (with just adding links to columns) is here: http://williambennettiv.com/ (used just for testing) The wrapper=div is just with the div, the "desired look" is how I'd ultimately like to style it so each post does not run into each other and I can right-justify rather than full.

  10. Bill Erickson
    Member
    Plugin Author

    Posted 2 years ago #

    You'll want to style the .listing-item in your style.css file. Something like this:

    .listing-item {
    padding-bottom: 10px;
    text-align: right;
    }
  11. williambennettiv
    Member
    Posted 2 years ago #

    ANDDDD BINGO! Needed another cup of coffee this morning clearly! Hadnt had it in my CSS so I wasnt looking for it!

    Thank you BOTH (Bill & Daymobrew) for awesome help - and thank you bill for a great plugin!

  12. Hawkman14
    Member
    Posted 2 years ago #

    Hey guys,
    Great stuff!

    My problem is that I am trying to get my text to align to the top - right next to my thumbnail image. Right now the excerpt text keeps going to the bottom of the thumbnail image.

    I tried to fix this with a CSS div but it just ignored my div code. I am using:

    [display-posts image_size="thumbnail" category="news" posts_per_page="-1" include_date="true" include_excerpt="true" wrapper="div"]

  13. daymobrew
    Member
    Posted 2 years ago #

    Can you post a link to your site?

  14. Hawkman14
    Member
    Posted 2 years ago #

    Sorry not yet since it is just an IP address I am using for a client until we can port over their site. I am not allowed to post it for security reasons.

    I had to give up using this plugin and got it work instead using List Category Posts plugin

  15. daymobrew
    Member
    Posted 2 years ago #

    Can you post the code that is generated by this plugin?
    You can use http://pastebin.com

  16. Hawkman14
    Member
    Posted 2 years ago #

    I don't think it would help since I also had to create and make changes to template.php file to get it to work

  17. daymobrew
    Member
    Posted 2 years ago #

    That should not have been necessary but it's good that you have an alternative solution in List Category Posts plugin

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic