Support » Themes and Templates » Styling by Category using wp_get_archives

  • I’m building a fairly large site that has a “most recent posts” section on the main page.

    So far, I’ve been using the wp_get_archives function with good success to bring up a list of the most recent posts. However, I have different categories for different topics of posts, and I want to be able to style each post listed depending on what category it is from.

    Is this easily done with wp_get_archives? Can I find a way to identify and style each post depending on category?

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    (@esmi)

    Forum Moderator

    wp_get_archives only displays a list of links to post – not the actual posts themselves. Are you talking about styling each one of these links differently? If so, that not possible with wp_get_archives.

    Yeah, sorry, that’s what I want to do. Style each link differently depending on category.

    If this isn’t possible with wp_get_archives, is there a similar function that would provide for this?

    esmi

    (@esmi)

    Forum Moderator

    Not a single function, no., You need to build a script that used custom queries to grab the relevant group of posts by date, then in a loop, grab the first category assigned to each post and add the category slug as a class to the final generated link.

    Not trying to be needy, but I’m not yet a pro at PHP. Any chance you could flesh out what you’re proposing here?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Styling by Category using wp_get_archives’ is closed to new replies.