Support

Account

Home Forums Front-end Issues Newly Created Layout Does Not Show When Published

Solved

Newly Created Layout Does Not Show When Published

  • Hi there! Thanks in advance for the great plugin.

    Here’s my issue:

    1. I’ve taken over a site that makes extensive use of the fields feature.
    2. I have added a new layout to the existing flexible field and wish to test it by adding it to a page, but when I hit publish (on staging) the new field does not display when I load the page (it can however be successfully saved).
    3. I can confirm that it is possible for example to duplicate existing filled-out fields (in the page editor) in which case they do show up.
    4. I fear there is some setting on my new field that I have misconfigured that causes it to be omitted when displaying the page.

    Some background on the set up:

    1. The pages on our site all have a single field, of the type “Flexible Content”
    2. It includes various types.
    3. I have added my own layout, consisting of a title and an image gallery.

    I have tried a hard refresh.

    Any thoughts?

  • Somewhere in your theme’s PHP code there is a loop, see this page https://www.advancedcustomfields.com/resources/flexible-content/

    In that loop the code is doing something based on the name of the layout. You will have to add new code for your new layout and how you add this code will depend on how the previous developer coded the theme.

  • Hi John,

    Thank you so much for your reply!

    This is the closest thing I can find:

    <?php if( have_rows('rows') ) : ?>
    		<?php while ( have_rows('rows') ) : the_row(); ?>
    			<?php get_template_part( 'blocks/content_rows/' . get_row_layout() ) ?>
    		<?php endwhile ?>
    	 <?php endif ?>

    This is from the page template in the theme files, I can confirm that it’s the correct template. It seems it is merely pulling the rows field, without referencing subfields, could that be? Or is there some more code somewhere else?

  • That is what you were looking for.

    There is a folder in your theme .../block/content_rows/
    In this folder there is a php file for each of your layouts
    {$layout_name}.php
    To add a layout you need to create a new php file in that folder with a name that matches your new layout name. Then you need to add code to that new file that will be used to display the content of your layout.

  • Thank you so much for the help!

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

You must be logged in to reply to this topic.