Using wp_query to show a random post from a specific category (3 posts)

  1. kasperbs
    Posted 6 years ago #

    Hi I need some help with a wp_query script. Here's what I need to do.

    1: Make an array of all the posts from the 'Events' category that have a value in the 'articleimg' cutsom field.

    2: Return the value of the 'articleimg' custom field, and print it inside a IMG tag.

    3: Print the title value of the selected post, and permalink it.

    Thanks in advance

  2. MichaelH
    Posted 6 years ago #

    1. See the Custom Field Paramenters in the query_posts() article.

    2. One example to consider: http://justintadlock.com/archives/2007/10/27/wordpress-custom-fields-adding-images-to-posts

    3. See the WordPress Default theme's index.php for good example of this.

  3. kasperbs
    Posted 6 years ago #

    Thanks for the links. I had a look at them and think it might be a little too technical for me.

    I've decided that I don't need the custom field image value anyway. I simply need a random post from the 'Event' category displayed at the top of my index page.

Topic Closed

This topic has been closed to new replies.

About this Topic