Support

Account

Forum Replies Created

  • Ok, solved it.
    Changed:

    
    <?php if (get_row_layout() == 'paragraph_content'): ?>
    

    To:

    
    <?php if (get_row_layout() == 'paragraph_content' && get_row_index() == 1): ?>
    

    and removed the break… all works as it should. No need for putting post, or cat, IDs in the fields!

  • If I remove the <?php break; ?> from the flex content loop, they all work, BUT if there is more than one paragraph content type, they’ll all show

  • Interestingly, the 1st post, of the SECOND loop for the flexible content DOES show the paragraph.. it’s just any consecutive posts in that get_posts loop, that don’t show the paragraph.

  • I have a similar issue, though with multiple Flexible Content loops on the Category page.

    My goal is to just get the first ‘paragraph’ content type for each post (these are custom post types with specific content defined for them, via ACF.

    So, if I use:

    
    <p class="lead">	
    	<?php if (have_rows('flexible_content_types')): ?>
    
    		<?php while (have_rows('flexible_content_types')): the_row(); ?>
    
    			<?php if (get_row_layout() == 'paragraph_content'): ?>
    				<?php echo truncate( get_sub_field('content' ), 120); ?>
         		<?php break; ?>
    			<?php endif; ?>
    
    		<?php endwhile; ?>
    
    	<?php  else: ?>
    		NO CONTENT
    	<?php  endif; ?>
    </p>
    

    It works, for the FIRST ONE.. then I run another loop:

    
    <?php
    	$featured = get_posts( array(
    		'post_type' 		=> 'post',
    		'numberposts'		=> 2,
    		'tag' 			=> 'featured',
    		'cat'                 => 3,
    		'ignore_sticky_posts' => 1,					
    		'offset'			=> 0
    	));
    		if ( $featured ): ?>
    			<?php foreach( $featured as $post ):  setup_postdata( $post ); ?>
    ... etc.. and run flex content loop here...
    

    and use the same flexible content loop from above.. doesn’t work on the second, third, etc. loops.

    Any ideas? What am I doing wrong here?

    IF I use the recommended code from above:

    $object = get_queried_object();
    $post_id = $object->taxonomy.’_’.$object->term_id;

    Then one of the flexible content loops works, the others do not…

    any suggestions ?

  • I’ve been tinkering and finally found something that works:

    
    		<form method="get" action="" onchange="submit();">
    			<div class="input-group">
    				<?php
    				global $wpdb;
    				$meta_key = 'item_oem';
    				$data = $wpdb->get_results($wpdb->prepare( "SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key) , ARRAY_N  ); ?>
    				<select class="custom-select" id="oems" aria-label="oems" name="item_oem" >
    					<option selected>Search By OEM</option>
    					<?php foreach( $data as $value ): ?>
    						<option value="<?php echo $value[0]; ?>"><?php echo $value[0]; ?> </option>
    					<?php endforeach; ?>
    			  </select>
    			  <div class="input-group-append">
    			    <a href="/inventory" class="btn btn-secondary" type="button">Clear Filter</a>
    			  </div>
    			</div>
    		</form>
    
    

    I’ll definitely look through your suggestions as well, and see which one works the best.. I don’t want to take a hit on performance just for a filter 🙂

    Thank you!

  • The purpose of the dropdown is to provide a way to filter the posts on the archive page, by OEM (the custom field value).

  • It’s a text field, added to each inventory post.

Viewing 7 posts - 26 through 32 (of 32 total)