Support

Account

Forum Replies Created

  • Jeez, that was far more help than I expected! Thank you! I’ll give this a try and post my results. Cheers!

  • Hi, Jonathan,

    Works like a charm! I can’t thank you enough for the guidance!

    Have a great day!

  • I realized that on the way home yesterday when thinking about it. Wow, that was a dumb oversight. I’ll try it and get back to ya. Thanks. 😉

  • Hi, Jonathan,

    First of all, thanks for the input! I know what you mean about the deprecated code. I’m working on a WP site that someone else built. Not an excuse, but yeah.

    I used the first function you posted since I’m using only one repeater in my group. I tried using the code you posted but it’s not showing any posts in the desired area of the page. The page loads the rest of the content so there is that.

    Here’s the code I’m using based on what you shared:

    <?php
    // args
    $args = array(
    	'posts_per_page'	=> 1,
    	'post_type'		=> 'profiles',
    	'meta_query'	=> array(
    		'relation'		=> 'AND',
    		array(
    			'key'		=> 'repeaterfieldname_%_year',
    			'compare'	=> '=',
    			'value'		=> '2015',
    		),
    		array(
    			'key'		=> 'repeaterfieldname_%_level',
    			'compare'	=> '=',
    			'value'		=> 'GRAND PRIZE',
    		)
    	)
    );
    
    // query
    $the_query = new WP_Query( $args );
    ?>
    <?php if( $the_query->have_posts() ): ?>
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    	
    	<section class="winner-level">
    		<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    		<?php if(get_field('awards_given')): ?>
      		<?php while(has_sub_field('awards_given')): ?>
    	
    		<?php if( get_sub_field('year') ): ?>
    		
    		<p><?php the_sub_field('program'); ?> - <?php the_sub_field('program_category'); ?></p>
    		<p><em><?php the_sub_field('campaign_title'); ?></em></p>
    		<p><strong><?php the_sub_field('level'); ?></strong></p>
    		
    		<?php endif; ?>
     
    		<?php endwhile; ?>
     		<?php endif; ?>
    	</section>
    
    <?php endwhile; ?>
    <?php endif; ?>
    
    <?php wp_reset_query();	?>
    

    Thoughts? Note that ‘GRAND PRIZE’ is in caps in the repeater field settings, which is why I made it such in the array.

    Cheers

  • Here’s my code to show where I’m stuck. Note that this is using one meta value and not more than one, which is what I’m looking for. This code doesn’t work. It ignores the meta name and value in the args array.

    <?php 
    	$args = array(
        'posts_per_page' => 1,
        'post_type' => 'profiles',
    	'orderby' => 'ID',
    	'order' => 'DSC');
    	'meta_name' ==> 'year', //not working
    	'meta_value' ==> '2015', //not working
    	query_posts($args);
    ?>
    
    <?php while ( have_posts() ) : the_post(); ?>
    			
    <section class="winner-level">
    	<h3><a>"><?php the_title(); ?></a></h3>
    	<?php if(get_field('awards_given')): ?>
      	<?php while(has_sub_field('awards_given')): ?>
    	
    	<?php if( get_sub_field('year') ): ?>
    		
    	<p><?php the_sub_field('program'); ?> - <?php the_sub_field('program_category'); ?></p>
    	<p><em><?php the_sub_field('campaign_title'); ?></em></p>
    	<p><strong><?php the_sub_field('level'); ?></strong></p>
    		
    	<?php endif; ?>
     
    	<?php endwhile; ?>
     	<?php endif; ?>
    </section>
    
    <?php endwhile; ?> 
    
    <?php wp_reset_query(); ?>
    

    Cheers!

  • Yeah. I’ve been Googling the heck out of this and have yet to find a solution.

Viewing 6 posts - 1 through 6 (of 6 total)