• Hi,

    This is probably already somewhere but having a few difficulties with what exactly to call it/it’s called.

    Basically I just want to know what the most efficient and therefore hopefully the ‘best practice’ would be to achieve the following:

    My site is a news site and therefore has a number of categories. Most of the homepage & landing pages are made up of small loops of the, say, most recent 10 posts from a category.

    So if I wanted to create a reusable ‘loop’ or ‘content node’ (name?) for say category A, B, C etc what’s the best and most efficient way? Is it a function or a specific loop-x.php page, something else?

    Hard to find an example but on the Beeb (http://www.bbc.co.uk/news/) they have the ‘Business, Health, Education’ etc snippets (half-way down) I’d like to have similar that I can just call on any page I wish.

    Thanks in advance for the help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • What do you mean by “re-usable”?

    Thread Starter jdku

    (@jdku)

    Hi esmi, just mean so that i can call it from the homepage or from a specific category template or a page or wherever I wanted really. re-usable might not be the correct word in this instance!
    Thanks

    In that case, it might be best to create a function in functions.php that ran a secondary loop using parameters passed to it (category id, number of posts etc). To create the loop itself, I’d suggest you use WP_Query.

    Thread Starter jdku

    (@jdku)

    Hi esmi, ok cool thank you. I wasn’t sure what would be considered the best way to achieve it. A function is good for me! Thanks for your help.

    No problem. 🙂 If you have any problems wrangling the function into shape, we should be able to help with that too.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Best Practice For Small Loops’ is closed to new replies.