Support » Fixing WordPress » Loop help please: selective post display on index

  • I’ve been going over this:
    in an effort to roll my own customizations into my blog home page. Great page of help!

    Specifically, I’d like to show the most recent post from any parent category. I believe that $wp_query->post requests X number of posts (determined in options > reading) and drops those into an array. What needs to happen next is to extract the posts from that array where the post category doesn’t have a parent (this identifies them as posts in a parent category) and drop those into a new array. Then, I need to extract the newest post from this new array and display it on the page. I think I have the idea behind how this would work, but I’m light on my PHP code knowledge. Any suggestions? All comments welcome.

    Elsewhere on the page, I’d like to do something similar, except rather than pull posts from a parent category, I would like to pull posts from any category where the category name contains a specific string. Again, I think I need to loop through the posts in the original array and extract those where the cat has the string in it’s name, and dump those to a new array. Then, I’d pull the latest post from this array to display on the page. (Or, maybe the second array is not needed, if both the condition and number of posts could operate on the original post array.)

    In order for this to work, I recognize that within the number of posts originally queried (determined in options > reading), there would need to be at least one that satisfies each of the conditions above, otherwise there would be no posts to display. That’s cool, I can deal with that. But…

    Can anyone offer some code advice to get me started on these two customizations? I imagine the code would come in handy for many who have similar endeavors with WP.

    JF 😉

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Loop help please: selective post display on index’ is closed to new replies.