I think It's better to use query_posts()
as you can use The Loop default structure.
As for the custom fields (Using ACF Plugin), you're using the_field()
, which automatically echoes the retrieved field value. You can use, in other hand, the get_field()
function, which just returns the value of the field.
You could do something like this:
// Query all posts from 'fact-sheet' post_type
query_posts(array(
'numberposts' => -1,
'post_type' => 'fact-sheet',
'order' => 'ASC',
// Getting all posts, limitless
'posts_per_page' => -1,
));
// Loop throught them
while(have_posts()){
the_post();
echo '<span class="fact-sheet-title">' . get_the_title() . '</span><br />';
echo '<p><span class="fact-sheet-summary">' . get_field('fact_sheet_summary') . '</span></p>';
// Echos the link to PDF Download
echo '<p><a href="'. get_field('fact_sheet_pdf_link') .'" target="_blank">Click here to download as PDF</a></p>';
}
// Once you're done, you reset the Default WP Query
wp_reset_query();
In case you might need further explanation about wp_reset_query()
, check this out.