Home Forums Add-ons Flexible Content Field Flexible Content to Build 404? Reply To: Flexible Content to Build 404?

  • Okay I have the 404 page set within settings > reading, and I think I’m like halfway to getting it working on the frontend. I have this code in the 404.php template:

    $post_id = intval(get_option('error_page'));
    if (!empty($post_id)) {
    $post = get_post($post_id);
    get_template_part('page'); // this is the part where I think I have it wrong?

    The normal template that calls all of my flexible content rows is page.php so that’s why I set that in the line for get_template_part. However, it only reads the container div with empty content inside. (This code works on every other page just fine.) I know that just page.php isn’t technically part of a template, so maybe that’s why it doesn’t work? This is the content for that:

    <div id="page__content">
        $sectioncount = 0;
    		while ( have_posts() ) :
    			// are there any rows within within our flexible content?
    	if( have_rows('page_content', $id )): 
    		// loop through all the rows of flexible content
    		while ( have_rows('page_content', $id )) : the_row();
            <?php get_template_part('template-parts/section', 'open');	?>
    			<?php	get_template_part('partials/page-content/'. get_row_layout());			?>
    		<?php get_template_part('template-parts/section', 'close');	?>
    		endwhile; // close the loop of flexible content
    	endif; // close flexible content conditional
    		endwhile; // End of the loop.

    See image attached for how it shows up on frontend. I really appreciate your help!