WordPress.org

Ready to get started?Download WordPress

Forums

recent posts by category? (26 posts)

  1. dss
    Member
    Posted 9 years ago #

    i want to put 5 0r 10 recent posts from specific categories on certain pages throughout my site.
    i have looked over the various topics for "recent posts" and while it seems that using archives is the best way, the only result i get from adding the code
    <?php get_archives('postbypost','20','html'); ? >
    to my side bar is a long list of all the entries in all the categories. how do i know what the '20' and 'html' additions mean in this application?
    how can i call all the posts from the archives in category 20 in the sidebar of a given page?
    is there a simple answer for this?
    please help.

  2. dss
    Member
    Posted 9 years ago #

    What exactly do you mean by "certain pages"?

    I have broken my site into "sections." rather than installing individual copies of WP for my Journal, Essays, News, etc... i have used sub folders, separate css, index.php, and often sub.php files to help the site's readers know where they are, and have a more interesting experience.

    Do you mean, for example, when someone is purusing a specific category then the recent entries list shows only the newest entries in this category?

    Yes, so on each unique index (for each unique section) it would be ideal if the recent posts from that section were called into the sidebar for easy reference by the reader.
    I am going to follow the above suggestion and read up on http://wiki.wordpress.org/get_archives .
    i'll post my findings here if you are interested.

  3. dss
    Member
    Posted 9 years ago #

    < ul >
    < li id="archives" >Recent Entries:
    < ?php get_archives('postbypost','10','html'); ? >< /p >
    < /ul >< /li >

    bah... this looks terrible, and isn't really anything i can tell what to grab.
    and yet, it's right there in the narchives.php...
    llike it's a hair on my tongue...
    driving me insane...
    cack-cack...

  4. dss
    Member
    Posted 9 years ago #

    i give up...
    i am calling friends now, asking for a ride to the hospital. i need to be drained, steamed, folded into a crisp brown bag, and saved for later tonight.
    71 hours... no love.
    dss

  5. thepete
    Member
    Posted 9 years ago #

    So, still no solution for this? This would be a very cool feature...

  6. raingrove
    Member
    Posted 9 years ago #

    is dss guy still alive?

  7. smbro
    Member
    Posted 9 years ago #

    What's the verdict?

    This is a very useful feature.

    someone else wrote an Ugly Hack around this; noone's written something more pluggable. don't know why this couldn't be a plugin instead of the ugly hack, though.

    j.

  8. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

  9. navid
    Member
    Posted 9 years ago #

    This is the type of thing that my WP-Exec plugin is exactly for. Unfortunately, for some oddities, my plugin has got no love even though I think its pretty damn useful!

    http://www.navidazimi.com/projects/wp-exec/

    Then, in ANY post or page, simply add:

    <ul>
    <exec type="function" name="get_archives" params="postbypost, 20, html" />
    </ul>

    Pretty damn sweet huh? But no, nobody loves Navid and his hard work.

    The Bitter One.

  10. Joshua Sigar
    Member
    Posted 9 years ago #

    Well, your plugin is relatively new, so you need to promote it more :)
    Did you list it in wiki page, by the way?

  11. navid
    Member
    Posted 9 years ago #

    Thanks for trying to make me feel better alphaoide. I added it to the Wiki. Let's see if I get some love now.

  12. smbro
    Member
    Posted 9 years ago #

    hey how does the exec help get recent posts by category?

  13. pericat
    Member
    Posted 9 years ago #

    I did a plugin for this last summer. Not tested with 1.5 yet, but it's rightcat.tar.gz, downloadable from http://pericat.ca/downloads/

    For what it's worth, the photolog, where I've been using it since, is here.

  14. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    navid, I guess you could use the 'function' option in your plugin for this? I don't see how to do it straightforwardly, though. An example on your site might be good.

  15. navid
    Member
    Posted 9 years ago #

    Pericat, four replies above your post I already posted the sample code:

    <ul>
    <exec type="function" name="get_archives" params="postbypost, 20, html" />
    </ul>

    Enjoy.

  16. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    That was me, navid, not pericat. :)

    This does not, though, display posts from a particular category.

  17. smbro
    Member
    Posted 9 years ago #

    what are the chances of this actually working on WP 1.5? i can't get it to display anything witih WP 1.5 beta.

    j.

  18. smbro
    Member
    Posted 9 years ago #

    sorry didn't read the instructions well enough--we use the category *id* and not category name. thanks,

    j.

  19. smbro
    Member
    Posted 9 years ago #

    actually -- having trouble with this.

    when i call this without any more arguments than the post count, everything's hunky dory (well, it works just like the get_archives/postbypost), but when i try to specify the category ID, the SQL it returns is valid (popped the SQL in and it returns the proper results), but the results do not display at all.

    j.

  20. pericat
    Member
    Posted 9 years ago #

    Which one are you having trouble with, smbro?

  21. smbro
    Member
    Posted 9 years ago #

    [whoa can't believe bbPress doesn't strip HTML! let's try this post again--]

    http://www.coffee2code.com/archives/2004/08/27/plugin-customizable-post-listings/

    basically calling it as in the following example:

    c2c_get_recent_posts(3, "","34");

    doesn't work for me. funny thing is; i had it print the underlying SQL, and using the SQL, it *is* bringing back the proper posts from the category.

  22. In your example you don't define a format string; in essense, you're telling the function not to display anything. Try adding a format string and see if it works:

    <ul>Recent Posts
    <?php c2c_get_recent_posts(3, "<li>%post_URL%<br />%post_date%</li>", "34"); ?>
    </ul>

  23. smbro
    Member
    Posted 9 years ago #

    thank you so kindly. makes perfect sense. :D duh....works just fine.

    j.

  24. Shirohagen
    Member
    Posted 9 years ago #

    OK, I'm a total newbie to this WordPress stuff, I've spent days hacking about with php stuff to get my blog going at http://www.holster.co.uk/blog.

    I have catagories for books, films and music etc for when I write about something I've read or seen. I'd like to be able to do a recent posts by category, so I can have a "Last 3 books I read" link section etc etc. This thread seems to be asking the same thing, but is there a definative answer here? I don't speak PHP!

    Help!

    ®

  25. moshu
    Member
    Posted 9 years ago #

    Use the plugin linked to in the third post above yours, and then use the call posted by coffee2code above. Replace 34 with your cat ID#.

  26. Shirohagen
    Member
    Posted 9 years ago #

    That's great, cheers Moshu & coffee2code, I couldn't see my nose for my face there!

    ®

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.