Support

Account

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

Unread

Cannot display Flexible Content in Category Archives

    • goto11

    • February 5, 2019 at 3:47 am

    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)

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.