Home › Forums › General Issues › Generating WP archive if an Image field is used › Reply To: Generating WP archive if an Image field is used
Just so there’s a working solution posted for whomever might need it, here’s what I came up with. Thanks for your help.
$striptype = sanitize_text_field( get_query_var( 'striptype' ) ); // calls the striptype from the URL and sanitizes the input so we can have one archive page that brings up archives in different languages
$posts = get_posts(array(
'posts_per_page' => 25,
'post_type' => 'post',
'orderby' => 'date',
'order' => 'ASC',
'meta_query' => array (
array (
'key' => $striptype, //this queries the metadata on the strips, in this case the advanced custom fields, looking for any that are not empty
'value' => '',
'compare' => '!=',
),
),
));
and then further down to actually display the retrieved images there’s one of these code blocks for every language:
if ($striptype == 'spanish_strip') {
$image = get_field('spanish_strip');
$size = 'full'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
//echo "<strong>Spanish Strip:</strong><br>";
echo wp_get_attachment_image( $image, $size );
echo "<br><br>";
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.