Support » Plugins and Hacks » Hacks » Loop through every post in a category and grab a custom field value

  • Hello everybody, my current task in a WordPress project is to loop through a custom type category (reviews_cat) and find every post within (custom type ‘reviews’), grab a custom field value (value_1) and have it available to manipulate as I need (these values will be digits and I will be adding the total value per category then dividing by the amount of posts in that category) I’m trying to come up with the most efficient answer to this, maybe somebody here has a proper method that I can use.

    Thanks,
    Crayz

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I would think using $wpdb methods to query the database to get only the values you need would be more efficient than retrieving all the posts and their associated baggage.

    Then you can just step through the returned array to do what you need to do with the values contained.

Viewing 1 replies (of 1 total)
  • The topic ‘Loop through every post in a category and grab a custom field value’ is closed to new replies.