• If you take a peak at this site’s sidebar: https://www.beyondrobson.com/ you will see that in the sidebar they have a ‘Recently In’ section that lists categories with the 2 most recent posts for each category.

    Can this be done in WP and if so how would one do this?

    Thanks
    Fi

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter fionagilbert

    (@fionagilbert)

    Hmmm thanks for that but I don’t think it will do what I need. This is how I would like it to look:

    Category 1
    Category 1’s Most recent post
    Category 1’s 2nd Most Recent Post

    Category 2
    Category 2’s Most recent post
    Category 2’s 2nd Most Recent Post

    etc.

    Any other options?

    Thank you

    Thread Starter fionagilbert

    (@fionagilbert)

    Anyone?

    You could try to have different calls for that plugin with different tags for each category. Did you try it before saying “I don’t think it will do what I need”…?

    Thread Starter fionagilbert

    (@fionagilbert)

    moshu, yes I did ?? I just wondered if there was another way to do what I require and thus far have had no joy.

    Thanks

    There’s a ton of threads on this forum asking this question… believe me, I’ve read many of them. It seems possible but I have not found 1 clear explantation of how.

    It shouldn’t need a plugin, this can be done with the right PHP calls, I just don’t know how. Basically you probably just need to write multiple loops, sorta like this

    LOOP1
    Call Only Category 1
    List 2 headlines
    END LOOP1

    LOOP2
    Call Only Cat2
    List 2 headlines
    END LOOP2

    You’ve got the right idea DGold and you could do that (see Multiple Loops in the Codex for more info). But that’s essentially what this plugin is doing – running mini loops with specific criteria.

    To get the result you want with the plugin just do this:


    <ul>
    Category One
    <?php c2c_get_recent_posts(2, "<li>%post_date%: %post_URL%</li>", "0000"); ?>
    </ul>

    <ul>
    Category Two
    <?php c2c_get_recent_posts(2, "<li>%post_date%: %post_URL%</li>", "0000"); ?>
    </ul>

    You’ll need to replace “0000” with your category ID (check manage->category to find that). You can also change how the listings display. See the plugin homepage for more info on that.

    Thread Starter fionagilbert

    (@fionagilbert)

    Ming,

    Thanks for that and I understand what you say but I really don’t want to manually code the categories in case I ever change them.

    I just thought that we would be able to create dynamically the categories and some recent posts from those categories.

    Can it be that hard?

    Thank you

    Yup, kinda ??

    The code you would need has to do two things. 1) Query the database for a list of all your categories and then 2) loop through that list and for each category do another query to get and display the two most recent posts.

    Whether it’s difficult or not really depends upon how good you can code PHP. Ideally you’d want to create this as a plugin so you could just drop a quick get_recent_posts_from_categories() function in your sidebar.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Can this be done with categories in WP’ is closed to new replies.