WordPress.org

Ready to get started?Download WordPress

Forums

Postlist Shortcode
[resolved] can't get more than 5 posts to be listed (13 posts)

  1. James Revillini
    Member
    Plugin Author

    Posted 2 years ago #

    I've got way more than 5 news items, yet this query does not show more than 5. Any suggestions?

    [postlist query="post_type=news&numberposts=9999&posts_per_page=9999"]

    Thanks,
    Jim

  2. Pat Hawks
    Member
    Plugin Author

    Posted 2 years ago #

    Sorry this is all so poorly documented.
    Try this instead.

    [postlist post_type="news" numberposts="9999"]

  3. James Revillini
    Member
    Plugin Author

    Posted 2 years ago #

    No problem ... but correct me if I'm wrong ... the plugin only queries based on the $query var, not the $atts array.

    http://pastebin.com/5HEX5Mmd

  4. James Revillini
    Member
    Plugin Author

    Posted 2 years ago #

    I rewrote this a bit since populating $query is no longer the prefered method. i did not make it backwards compatible but it wouldn't be that hard to let $query work still.

    http://pastebin.com/qLFqfaxJ

    Let me know how this works for you. I also added a bunch of comments.

    Ultimately, I'd like to add the ability to specify an output template with vars like 'before', 'after', and 'itemtemplate'. I'll post it when done.

  5. Pat Hawks
    Member
    Plugin Author

    Posted 2 years ago #

    Whoops. Haven't updated the code in the repository for a while.
    I'm using a newer version on my sites than what I've released.

    http://pastebin.com/GXm8ZyyP

    Adding this to the repo. If you'd like to work on this with me, I'd be happy to add you as a contributor.
    I've thought about adding template stuff, but just haven't had the need for my own sites.

  6. James Revillini
    Member
    Plugin Author

    Posted 2 years ago #

    LOL I figured.

    Heck yeah I'll work on this! Thanks for offering! Maybe I can work on the templating. How do you wish to discuss, or did the before/after/itemtemplate thing sound good enough?

  7. Pat Hawks
    Member
    Plugin Author

    Posted 2 years ago #

    Before and after would certainly be the easiest.
    Not super flexible, but I suppose hard core template devs won't be trying to mess around with shortcodes in the first place.

    I've added you as a committer to the repo. Do what you need to do.

  8. James Revillini
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Pat,
    I created a branch for my changes 1.1.x.

    I haven't updated docs yet because I wanted you to have a look at it and see what you think. You might have better suggestions on how to implement the new attributes. My commit comment explains the new accepted attributes.

    The things I'm wondering about the code itself is:
    * is it still readable?
    * should we extract the attribute array out to local variables so that we can reference them in a shorter way in the code, rather than always going $atts['whatever']
    * does using the global $post pose any problems? it hasn't for me, but maybe you know something I don't

  9. James Revillini
    Member
    Plugin Author

    Posted 2 years ago #

    This sucks. wpautop is messing up my whole plan here. It's adding extra </p> and <p> around my item template because the items template is just <li>some stuff</li>, so it thinks it needs to close out any previous paragraph and and start a new one after each item.

    I could use regex to strip them but it seems kludgy. Might have to tho.

  10. James Revillini
    Member
    Plugin Author

    Posted 2 years ago #

    ... or make it part of the plugin options but I wanted to be able ot do different things with each list.

  11. Pat Hawks
    Member
    Plugin Author

    Posted 2 years ago #

    I have no idea why I was using the global $post. Must have bumped my head.
    I don't think we need to extract the variables. Just adds code and chance of something getting screwed up.

    Now that we're allowing users to include their own HTML, I'm running the output through WP_KSES.

    It feels like the whole plugin is run through if ($posts) {
    It kind of gave me a headache. I may change it to if (!$posts) and return some comment about nothing found, but have not changed that yet.

    I like how things are shaping up.

  12. Pat Hawks
    Member
    Plugin Author

    Posted 2 years ago #

    Perhaps this would be more trouble than it's worth, but what if instead of using a bunch of shortcode attributes for the template, we used the shortcode content?

    [postlist]
    <li><a href="{LINK}">{TITLE}</a></li>
    [/postlist]
    [postlist]
    <ul>
    <li><a href="{LINK}">{TITLE}</a></li>
    <ul>
    [/postlist]
    [postlist]
    <ul>
    <li><a href="{LINK}">{TITLE}</a></li>
    <li><a href="{LINK}">More Posts...</a></li>
    <ul>
    [/postlist]

    The code would explode the content by line into an array. If there was only one line, it would be used as itemtemplate. If there were two lines, the second would be used as morelinktemplate (without the {TITLE}).

    If there were three lines:

    before
    itemtemplate
    after

    Four lines:

    before
    itemtemplate
    morelink
    after

    Thoughts?

  13. James Revillini
    Member
    Plugin Author

    Posted 2 years ago #

    Oh that's a great solution, but is the WP editor going to give you balls since you're putting HTML in the visual view? One possible side effect is that it would add wrapping UL tags. Another is that 'less than' gets turned into & lt;. I guess I'd worry esp. if the user switched back and forth between HTML and visual view.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic