Home Forums General Issues Getting all fields from a category


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

    • Elliot

    • July 18, 2013 at 2:35 pm

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.