• I feature 3 specials each in four “Featured sections” on my homepage. Right now I am doing it like this
    <?php $recent = new WP_Query( array( "post__in" => array(419,1409,1091) ) ); while($recent->have_posts()) : $recent->the_post();?>
    The thing is that I have to change the featured posts every day manually by putting in different ID’s. That’s not very elegant and it’s just pretty annoying since I have four “Featured Sections” on my homepage with 3 featured articles each.

    Is there a way to turn this process into an automatic one? I don’t add posts every day to the categories so “grabbing the most recent posts” would not help. I was basically thinking if I can add a “pool” of post ID’s somewhere from where the featured section grabs different ID’s every day … or something like that. I really don’t know if that is possible.

    Let me know if anyone has an idea what I can do about it.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter do77

    (@do77)

    anyone an idea?

    Either use categories, tags, or custom fields to specify where the posts are to appear and use one of these parameters with your query instead of the post__in array:

    cat=
    or
    tag=
    or
    meta_key=
    meta_value=

    The article, query_posts(), describes those parameters/arguments.

    Thread Starter do77

    (@do77)

    Hi MichaelH,

    I used categories at the beginning but the problem was that always the most recent posts were featured then. The problem is that I don’t add posts in some featured categories very often thus the section would show always the same posts. Thats why I was wondering if there is a way to automatically display different posts out of a specific category every day?

    Just give those posts a 2nd category, just for the day. Then tomorrow, delete the category from those posts and assign the category to a new set of posts.

    Thread Starter do77

    (@do77)

    Thanks MichaelH … I will try that and see if it works for me!

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

The topic ‘Automatic change of posts in an array!?’ is closed to new replies.