Support

Account

Home Forums Add-ons Flexible Content Field Cannot display Flexible Content in Category Archives

Unread

Cannot display Flexible Content in Category Archives

  • Hi there,

    My issue seems to be the same as this:

    https://support.advancedcustomfields.com/forums/topic/display-flexible-content-on-category-archive-page/
    But that didn’t fully answer things for me. Basically, I’m using Flexible Content in a ‘Rows’ Custom Post Type, to build content for each ‘Row’. These ‘Rows’ are then selected as Post Objects in an ACF ‘Options’ section. With me so far?!

    I then output the selected ‘Rows’ at the end of the site. This works in every part of the site except for the Catgeory Archives. Date & Author Archives are fine?

    It does seem to be connected in some way to calling the post ID before running the Flexible Content. Here’s my code:

    	<?php
    		$subfooter_post_objects = get_field('default_subfooter_rows','options');
    		if( $subfooter_post_objects ):
    		
    		echo '<div class="footerWrapper fullwidth clearfix">';
    	
    			foreach( $subfooter_post_objects as $post): setup_postdata($post);
    				
    					$postID = $post->ID;
    					
    					if ( have_rows( 'flexible_content', $postID ) ) :
    					
    					    while ( have_rows( 'flexible_content', $postID ) ) : the_row();
    							
    					        include(locate_template('flexible-content/'. get_row_layout() . '.php'));
    					
    					    endwhile;
    					
    					elseif ( get_the_content() ) :
    					
    					endif;
    		    
    			endforeach;
    			
    		echo '</div>';
    			
    		wp_reset_postdata();
    	
    		endif;
    	
    	?>

    It is causing an error when I try to call in the Post ID:

    Notice: Trying to get property of non-object in /home/vfa/public_html/wp-content/themes/vfa_0-3/footer.php on line 11

    Line 11 is:

    $postID = $post->ID;

    Any thoughts?

    Many thanks!

    Mat

Viewing 1 post (of 1 total)

The topic ‘Cannot display Flexible Content in Category Archives’ is closed to new replies.