Support

Account

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>";
    }