I created a field group called Brochures with 6 types. The field group is set as a Post Type. The individual “brochures” posts render as intended. What I would like is to display all of them on one page like a category page.
My initial attempt was to create an array like so
<?php
query_posts(array(
‘post_type’ => ‘brochure’,
‘showposts’ => 10
) );
?>
The get_field or get_field_object doesn’t seem to pull anything in.
<?php get_field_object(‘file_letter’, $post_id); ?>
I would greatly appreciate assistance on this. I hope I was able to describe what I am trying to do.
Not really enough information to really know what the problem is.
This is a basic query and loop, hopefully it helps you out. You’ll notice that the loop looks just like “The Loop” used for showing pages/posts/anything in WP.
$args = array(
'post_type' => 'brochure',
'posts_per_page' => 10
);
$brochure_query = new WP_Query($args);
if ($brochure_query->have_posts()) {
while ($brochure_query->have_posts()) {
$brochure_query->the_post();
?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<div>
<h2>A Custom Field</h2>
<?php the_field('file_letter'); ?>
</div>
<?php
} // end while have posts
wp_reset_postdata();
} // end if have posts
for more examples of querying posts and showing custom fields take a look at https://www.advancedcustomfields.com/resources/query-posts-custom-fields/