Home › Forums › Add-ons › Flexible Content Field › How to use ACF Pro Flexible Content with Single Page?
I’m developing a website with Flexible content. I’m using it as a builder basically.
I’m in the page section, e.g. Portfolio, and I can “Add row”. Awesome! ALl of these pages are using page.php where this code is displayed:
<?php
if( have_rows('template_blocks') ):
while ( have_rows('template_blocks') ) : the_row();
if( get_row_layout() == 'header_page' ):
get_template_part( 'templates/section', 'header-page' );
elseif( get_row_layout() == 'header_main' ):
get_template_part( 'templates/section', 'header-main' );
elseif( get_row_layout() == 'services_excerpt' ):
get_template_part( 'templates/section', 'services-excerpt' );
elseif( get_row_layout() == 'contact' ):
get_template_part( 'templates/section', 'contact' );
elseif( get_row_layout() == 'services_tabs' ):
get_template_part( 'templates/section', 'services-tabs' );
elseif( get_row_layout() == 'standards' ):
get_template_part( 'templates/section', 'standards' );
elseif( get_row_layout() == 'contact' ):
get_template_part( 'templates/section', 'contact' );
elseif( get_row_layout() == 'footer' ):
get_template_part( 'templates/section', 'footer' );
elseif( get_row_layout() == 'bar_secondary' ):
get_template_part( 'templates/section', 'bar-secondary' );
elseif( get_row_layout() == 'process' ):
get_template_part( 'templates/section', 'process' );
elseif( get_row_layout() == 'empty_bar' ):
get_template_part( 'templates/section', 'empty-bar' );
elseif( get_row_layout() == 'form_section' ):
get_template_part( 'templates/section', 'form-section' );
elseif( get_row_layout() == 'callout' ):
get_template_part( 'templates/section', 'callout' );
elseif( get_row_layout() == 'ready_bar' ):
get_template_part( 'templates/section', 'ready-bar' );
elseif( get_row_layout() == 'portfolio_excerpt' ):
get_template_part( 'templates/section', 'portfolio-excerpt' );
elseif( get_row_layout() == 'services_card' ):
get_template_part( 'templates/section', 'services-card' );
elseif( get_row_layout() == 'about_author' ):
get_template_part( 'templates/section', 'about-author' );
elseif( get_row_layout() == 'work_featured' ):
get_template_part( 'templates/section', 'work-featured' );
elseif( get_row_layout() == 'work_all' ):
get_template_part( 'templates/section', 'work-all' );
elseif( get_row_layout() == 'work_tab' ):
get_template_part( 'templates/section', 'work-tab' );
elseif( get_row_layout() == 'action_block' ):
get_template_part( 'templates/section', 'action-block' );
endif;
endwhile; endif;
?>
However, now I created Custom Post Type
Custom Fields ->
Show this field group in:
Post Type [is equal to] [Projects]
So I go ahead and create few projects. Now, in the code, I get the WP Query, so i can take these proejcts.
However, now I click a project, and where it goes? It goes to single.php page! How do I edit single.php page? There is no option like for a nromal page.
How do I say, add single page for portfolio, and add the flexible content?
Sure, I can add in the same code that that’s in page.php, but so what? Where do I go to view the single page in the WP admin dashboard?
I know it’s possible.
I have been trying to figure this out for a while now, and I can’t figure it out.
Here is the github repo if that helps: https://github.com/AurelianSpodarec/aurelianMegaPortfolio2018
Currently I have: Home, Services, Process, About, Contact, Portfolio.
All of them are using page.php, and when I go to Admin Dashboard page, I just ‘Add row’, and that way I can achieve unique look for every single page that I mentioned, apart from single.php, because how do I make single.php for projects? or services ?
Hopefully I’m following your question correctly so this expands the process for you.
The WP hierarchy will default to single.php
– if you’d like to create different templates for each Custom Post Type, you could use that as a jumping off point but then create single-projects.php
, single-services.php
to add different markup and styling.
Hi allisonplus,
Yes, absolutelly.
I just want to point out that I’m using ACF Flexible Content as my layout, with the functionality of the ‘Add Row’, so it’s essential to ahve the visual UI on the admin dashboard, like I do have the UI for each page.
Said that, there is no possibility for me to create a different template by just creating a single.php or single-projects.php, since I can’t ‘Add row’ with them, so all of the single-project.php will have the same header, footer and style, but it needs to be done with Flexible Content – I know it’s possible because people have done it.
The topic ‘How to use ACF Pro Flexible Content with Single Page?’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.