Support

Account

Forum Replies Created

  • Thank you very much! Your explanation of how the values are stored was exactly what I needed. In all my research, I’d never seen an example of a nested inside group. I appreciate your help more than you know!

  • Update: I have started to shift toward adding meta_query to my args and then put an if $count is greater than the query. My issue is that I can only get the $count to add up how many posts are in the CPT, instead of what matches the query. Have I gone the wrong way?

    Here is the new code I am trying to make work:

    $args = array(
        'posts_per_page'   => 500,
    	'orderby' => 'meta_value',
        'order'            => 'DESC',
       'meta_query' => 
      array(
        'relation' => 'AND',
        array(
          'key' => 'book_videos', // group
          'compare' => 'EXISTS'
        ),
        array(
          'key' => 'book_videos_bk_videos', // group + nested repeater --> I want to add another array here that adds in a subfield of the nested repeater but it just doesn't work
          'compare' => 'EXISTS'
    			),
    		
        ),
     
        'post_type'        => 'books',
        'post_status'      => 'publish',
  • Thank you for your suggestion. Yes, I am moving all closing statements to match. I have re-written this code with different if’s and while’s in different positions and the only way I get any output is by having the items where they are now. I cannot sort out what I am doing that isn’t working.

  • I’m not sure what changed but I decided to try some code I’d been working with previously and it has decided to work today (aggravating but I’ll take what I can get). For anyone in a similar boat, this is what I did:

    <?php query_posts(array(
            'post_type' => 'sponsor',
            'showposts' => -1,
    		'meta_key' => 'child_info_child_idnum',
    		'orderby' => 'meta_value',
    		'order' => 'ASC',
        	'post_status' => 'publish'));
    
    			if ( have_posts() ) :?>
    				
    				<ul id="spo_kids">
    					<?php while ( have_posts() ) : the_post(); 
    
    						if( have_rows('child_info') ): 
    					?>
    
    								<ul>
    
    										<?php while( have_rows('child_info') ): the_row(); 								$child_image = get_sub_field('child_picture');
     ?>
    
    															<li>
    																<div>
    
    																		<img src="<?php echo esc_url( $child_image['url'] ); ?>" alt="<?php echo esc_attr( $child_image['alt'] ); ?>" />
    																	<?php echo '<h5>';
    																		echo the_title();
    																		echo '</h5>';
    
    																		echo '<span class="c-dob">';
    																			echo 'DOB: ';
    
    																				if ( get_sub_field('birthday') ):
    																					echo the_sub_field('birthday');
    																				else: echo 'Unknown'; endif; 
    
    																		echo '</span>';
    
    																		if ( get_sub_field('date_verified') ):
    																			echo '<span class="c-verified">';
    																				echo 'Verified: ';
    																				echo the_sub_field('date_verified');
    																			echo '</span>';
    																		else: endif;
    
    																	?>
    																				<a class="spo-links" href="<?php the_permalink(); ?>#spo_form" />
    																					<?php if ( get_sub_field('currently_sponsored') == 'Special Need' ): ?>
    																						Special Need
    																					<?php else: ?>
    																						Sponsor Now
    																					<?php endif; ?>
    																				</a>
    																				<a class="spo-links" href="<?php the_permalink(); ?>" />Learn More</a>
    																</div>
    															</li>
    
    										<?php endwhile; ?>
    
    								</ul>
    
    <?php endif; endwhile; endif; ?>
  • Thank you so much for sending that over. I’ll explore it more tomorrow but wow, you were ambitious! One thing that I don’t see is a sorting of the repeater – which is something I need to do. I need the first repeater to be sorted by name (ABC) and then don’t really care about the second (I’d love to have that sorted as well but I’ll take what I can get!). From my research, in order to do the sorting, I need to use multisort, which requires the foreach. It’s about 3am my time so my brain might not be fully engaged at the moment. Can’t wait to take another look tomorrow!

  • Please! I would so appreciate seeing it. I haven’t been able to solve the issue yet so I am completely open. Thank you so much!

  • Thanks. I added this and had to put in a wp_reset_query (instead of reset post data) at the end of the previous call. Seems to be working now!

  • Thank you for your help, Keith! I’m not sure why I didn’t mark this as resolved. Very sorry and you are very appreciated!

  • I was able to figure it out. Never was able to get to the sub_field outside of the second nester so I put in a counter. In hindsight, it seems incredibly glaringly obvious but oh, well! Pasting for anyone else who might have the need. It might not be the smartest way to go about it but this did the trick for me:

     <?php 
    						
        if( have_rows('affiliations_&_links', 'option') ):
    
          while( have_rows('affiliations_&_links', 'option') ): the_row(); 
    					
        	if( have_rows('affiliations_repeater', 'option') ):
    				$x = 1;
    				echo '<ul>';	
    				while( have_rows('affiliations_repeater', 'option') ): the_row();
    						echo '<li>';
    						 // Flag for the first row
    						if ($x==1) :
              					echo '<h5>';
    						echo the_sub_field('link_type', 'option');
    						echo '</h5>';
           					else :  endif;
    						echo the_sub_field('al_name', 'option');
    						echo '</li>';
          			$x++; endwhile;  // ends affiliation repeater
    						echo '</ul>';
    		endif; // ends affiliation repeater
    	endwhile; // ends affiliation and links
    	endif;// ends affiliation and links
      ?>
Viewing 9 posts - 1 through 9 (of 9 total)