WordPress.org

Ready to get started?Download WordPress

Forums

Loop through every post in a category and grab a custom field value (2 posts)

  1. Crayz
    Member
    Posted 1 year ago #

    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

  2. bcworkz
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic