Support

Account

Home Forums General Issues Getting all fields from a category

Helping

Getting all fields from a category

  • Hi I have a category

    Within it all the posts are ACF, there are 10 posts.

    Currently I am doing this one by one

    `<h3><?php the_field(‘cdtitle’, 475); ?></h3>
    <p><?php the_field(‘cd_info’, 475); ?>
    <?php the_field(‘cdlabel’, 475); ?></p>`

    to get information,

    I would like to query the whole category and pull all 10 posts rather than writing the above code 10 times and changing the ID

  • Hi @lucania

    You should read up on the get_posts function over on the WP codex.
    You can use this function to find all post objects within a category (using the category paramters)

    Then, you can loop through the posts and then load the values using the post ID ($post->ID)

    Good luck!

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Getting all fields from a category’ is closed to new replies.