WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields Filtering Relationships by Tax (1 post)

  1. Jacob Roman
    Member
    Posted 8 months ago #

    I have the following code to list posts. But i need to filter them by a tax called scale. How would I add that to this code:

    <div id="masonry-loop" >
    
    			<?php 
    
    			$posts = get_field('cars_under_this_group');
    
    			if( $posts ): ?>
    			    <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
    			        <?php setup_postdata($post); ?>
    
    			        <div class="masonry-entry small-6 columns singleGroup">
    			        	<div style="background: #ffffff; border: 2px solid #333333; margin: 0 0 20px 0;">
    					<?php 
    
    					$posted = get_field('car_under_id');
    
    					if( $posted ): ?>
    						<div class="row">
    						<?php foreach( $posted as $p ): // variable must NOT be called $post (IMPORTANT) ?>
    						    <div class="small-6 columns">
    						    	<a class="glow" href="<?php echo get_permalink( $p->ID ); ?>">
    						    		<div class="productListThumb" style= "background:url(<?php the_field('thumb_image', $p->ID); ?>) no-repeat center 30%; display:inline-block; width: 100%; height: 155px; background-size: 97%; margin: 10px 0;"></div>
    						    	</a>
    						    </div>
    						<?php endforeach; ?>
    						</div>
    					<?php endif; ?>
    					<div class="row" style="padding: 0 30px 15px;">
    						<h2 style="margin: 0;"><?php the_field('name_of_rcs'); ?></h2>
    						<p style="margin: 0;"><b><?php the_field('detailed_title'); ?></b></p>
    						<p style="margin: 0;"><?php
    								$age = get_field('age_group');
    
    								if( $age == '8+') {
    									echo '<a href=" ' . get_site_url() . '/ages/8/">' . 'Ages: ' . $age . '</a>';
    								} elseif ( $age == '6+') {
    									echo '<a href=" ' . get_site_url() . '/ages/6/">' . 'Ages: ' . $age . '</a>';
    								} elseif ( $age == '4+') {
    									echo '<a href=" ' . get_site_url() . '/ages/4/">' . 'Ages: ' . $age . '</a>';
    								} else {
    									echo 'Ages: ' . $age;
    								}
    								?></p>
    					</div>
    				</div>
    			        </div>
    			    <?php endforeach; ?>
    			    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    			<?php endif; ?>
    		</div>

Reply

You must log in to post.

About this Topic

Tags