• hmichaels

    (@hmichaels)


    I’m currently making a website, and want to have a page which shows the most recent post from its subcategories.

    For example…

    News -> Entertainment -> Movies -> The Terminator (1984)
    News -> Entertainment -> Music -> The Beatles

    ‘The Terminator’ and ‘The Beatles’ might have 10+ news items each, but I only want the page to show the most recent one for each.

    I’m bad at coding, so this probably looks like hell to some people, but here’s how I’ve been doing it:

    (Category 10 is “News”, i.e. the topmost category.)

    [Code moderated as per the Forum Rules. Please use the pastebin]

    This works great. I have 13 posts across 4 categories, and I see only the most recent post in each of those 4 categories.

    The problem lies when I add a fifth category. If there is one post in the fifth category, it shows fine. If there are two or more, it ONLY shows the most recent most from the fifth category and hides the other 4 categories’ posts which were displaying fine until then.

    I can’t seem to figure this one out. Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter hmichaels

    (@hmichaels)

    Well, it seems after over two hours of banging my head against a brick wall, I discover the “solution” within 20 minutes of posting this.

    Apparently using “break” to break loops doesn’t work properly files which are included in other files, which pretty much rules out using “break” in WordPress.

    In case anyone is looking to do something similar, I made it even less elegant than it already was, but it seems to work:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Messy, but works.

    Thread Starter hmichaels

    (@hmichaels)

    Mods might as well delete this topic now, as anything remotely useful has been removed from visibility.

    Cheers!

    TimDesain

    (@timdesain)

    Thread Starter hmichaels

    (@hmichaels)

    Yep, will do in the future. Just saying that the issue is resolved and the thread is just taking up space now.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Strange loop problem when showing most recent post in category’ is closed to new replies.