Support

Account

Home Forums Add-ons Flexible Content Field Display flexible content on category archive page

Solved

Display flexible content on category archive page

  • Hello,

    I created some flexible content fields to use on pages and category archive pages.

    I have no issues with displaying the fields on pages but I’m having issues displaying the fields on category archive pages.

    The code I’m using is below:

    <?php if( have_rows('page_modules', $here) ):
    	while ( have_rows('page_modules', $here) ) : the_row();	
    		// TOP SLIDER
    			if( get_row_layout() == 'image_slider'):
    				require 'modules/top-slider.php';
    			endif;
    						
    		// IMAGE/VIDEO/TEXT 
    			if( get_row_layout() == 'image_video_text' ): 
    				require 'modules/image-video-text.php';
    			endif;
    
    	endwhile;
    	endif; ?>

    I’ve tried using the following code below on archive.php to display the category flexible content values. The results that are generated are from my home page….

    <?php
    	$categories = get_the_category();
    	$category_id = $categories[0]->cat_ID;
    			
              if( have_rows('page_modules', $category_id) ):
    		while ( have_rows('page_modules', $category_id) ) : the_row();	
    			// TOP SLIDER
    			if( get_row_layout() == 'image_slider'):
    				require 'modules/top-slider.php';
    			endif;
    						
    			// IMAGE/VIDEO/TEXT 
    			if( get_row_layout() == 'image_video_text' ): 
    				require 'modules/image-video-text.php';
    			endif;
    
    		endwhile;
    	endif; ?>

    Any ideas on how I can display flexible content on category archive pages?

    Any help much appreciated

    Thanks

  • The post id for ACF is "{$taxonomy}_{$term_id}"

    
    $object = get_queried_object();
    $post_id = $object->taxonomy.'_'.$object->term_id;
    
  • John,

    Thanks for the reply. Works a treat!

    Thanks again.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.