Support

Account

Forum Replies Created

  • Ok thanks – I thought that was the case as that’s similar to how we’ve been doing it, but wanted to double check there wasn’t a better way.

  • Ok thanks. So that would allow you to identify which posts had relevant values for the repeater field, and I’m guessing you’d then have to further filter by the sub fields to only output the rows you’re interested in?

    So to use my example we’re finding the posts that contain references to “Arsenal” in the team_% sub field, and then from those posts we need to output the values from only the rows that contain the team “Arsenal”.

    Is it possible to somehow sort the information by a value in the sub field? Eg: So that the relevant rows from the sub fields are sorted by the relevant startyear field for that row?

  • Hi John, Thanks for the reply – I had only included the part relevant to the post_object field, full shortcode is below:

    function productlist_func( $atts ){
    
    $output = new WP_Query( array( 
    	'post_type' => 'product',
    	'tag' => $atts['tag'],
    	'posts_per_page' => 100, 
    	'no_found_rows' => true,
    	'update_post_term_cache' => false,
    	'update_post_meta_cache' => false,
    	'meta_key' => 'positioning', 
    	'orderby'=> array( 
           'meta_value' => 'DESC', 
           'date' => 'DESC' 
        )
    	)
    ); 
    	
    if ($output->have_posts()) :	
    
    $ret = '<div class="productcont">';
    
    while ($output->have_posts()) : $output->the_post();
    		
    $ret .= '
    
    <div class="productitem">
    	<div class="pilogo">
    		<div class="sqlogo">';
    		
    
    $brand = get_field('brand');
    if( $brand ) : 
    $ret .= '<img src="' . get_field('square_logo', $brand->ID) . '" />';
    endif;
    
    		
    $ret .=	'</div>
    	</div>
    	<div class="pidetails">
    		<div class="pititle">
    			<a href="' . get_permalink() . '">' . get_field('product_title') . '</a>
            </div>
    		<div class="pitext">' . get_field('description') . '</div>
    	</div>
    	<div class="eovisit">
    		<a href="' . get_permalink() . '" class="pbutton">Claim</a>
    		<div class="piterms">T&Cs apply 18+</div>
    	</div>
    </div>
    
    ';
    	
    endwhile; 
    
    wp_reset_postdata();
    	
    $ret .= '</div>';
    	
    return $ret;
    
    endif; 
    
    }
    add_shortcode( 'productlist', 'productlist_func' ); 
  • Nevermind, figured it!

    For anyone else with the same question we needed to use: get_post_type( get_the_ID() ) and set it as a variable.

    Eg:

    <?php 		
    $post_type = get_post_type( get_the_ID() );
    if ( $post_type == 'horses'):?>
    	<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
    <?php else:?>
    	<?php the_title(); ?>
    <?php endif;?>
Viewing 5 posts - 1 through 5 (of 5 total)