- This topic has 11 replies, 4 voices, and was last updated 1 year, 5 months ago by Elvin.
February 3, 2021 at 9:07 am #1644469sporenborg
After I’ve been trying to figure out how to implement the ACF (advanced custom fields) in my GP environment for some time now without success and going crazy in the process, here are my questions for the pros:
1) Is it correct that I copy the single.php or page.php from the GP theme folder to the GP-child theme folder and give the filename a prefix for example “projects-single.php”?
2) Is it correct that I use my ACF code
<?php the_field( 'project_title' ); ?> <?php the_field( 'project_customer_website' ); ?> <?php the_field( 'project_customer_description' ); ?> <?php $project_picture = get_field( 'project_picture' ); ?> <?php if ( $project_picture ) : ?> <img src="<?php echo esc_url( $project_picture['url'] ); ?>" alt="<?php echo esc_attr( $project_picture['alt'] ); ?>" /> <?php endif; ?>
– as an example – after the code
/** * generate_after_entry_header hook. * * @since 0.1 * * @hooked generate_post_image - 10 */ ………………"
and before the code
/** * generate_after_entry_content hook. …………"
in front of it?
3) Where do I have to tell WordPress that I have now created a new projects-single.php?
4) Where can I select in a new post that I would like to use this projects-single.php template?
There used to be a plugin “ACF Frontend Display”, but unfortunately it is no longer available for download. With this plugin you could easily integrate the ACF into any page.
Many thanks in advance!February 4, 2021 at 3:48 am #1645330DavidStaffCustomer Support
not in the order of your questions but these are the top level steps you require:
1. you need to register your custom post type:
There are some tools to make that simpler:
This sets the parameters of what the CPT can do, the slug for the templates to be used and where its displayed in the Dashboard Menu.
2. Then you require your templates.
Take a copy of your the
Rename them so they match the slug of your CPT eg.
3. In your project.php file you will need to update this line:
4. Then you will edit the content-project.php to add your ACF Content etc.
Thats the simple overview of it…..
There are other tools that allow you to do this such as CPT UI or Toolset.February 20, 2021 at 7:46 am #1665736Marcus
Very helpful overview. Thank you David!February 20, 2021 at 8:51 am #1665783DavidStaffCustomer SupportFebruary 22, 2021 at 3:36 am #1667456sporenborg
Thank you very much, for your great support, David! Thanks to your clear instructions, I was able to get the ACF running on my Website.February 22, 2021 at 4:50 am #1667526DavidStaffCustomer SupportApril 19, 2021 at 3:16 am #1739886sporenborg
Hello David, I have to open the topic again and ask you for advice.
1) Your tutorial worked very well, however, I currently have the problem that the global settings of the customizer are not applied. Can it be because the single.php is now called single-project.php? Do I have to leave out the prefix “single-“?
2) And another question: In my case, I would like to display the logos of the customers on the start page. This currently works only before the generateblocks or after the generateblocks content. Can I include the logos by ID in the middle of the gblocks or in another way?
thanks a lot!April 19, 2021 at 5:15 am #1739982DavidStaffCustomer Support
1. The name of the template should not matter. What customizer setting isn’t applying to the template?
2. Unfortunately not – post templates calls
the_contentfunction – what they do not do is output stuff within
the_content. As you’re using ACF you could simply introduce more custom fields for to split your content into pieces.April 19, 2021 at 6:03 am #1740020sporenborg
Currently nothing is applying to the custom page content. I’m using custom CSS classes. Could that be the problem? Or maybe there’s something I’m not including in the file? Is it possible to add custom options for custom templates in customizer?April 19, 2021 at 11:43 pm #1741175DavidStaffCustomer SupportApril 20, 2021 at 1:01 am #1741245sporenborg
of course …April 21, 2021 at 12:18 am #1742710ElvinStaffCustomer Support
Can you specify which ones are you pertaining to?
If it’s the title text, color, and the other things on the ACF field output:
It won’t apply because you’re using a completely different class compared to the default template the theme uses.
Customizer settings apply its settings through the default class selectors, and since you’ve changed that on your template for the ACF field output, the global customizer settings won’t apply to them.
I’m not exactly sure I imagine what you’re trying to do. Can you provide any mockup image of how you want it to appear?
Is the logo dynamically changing depending on the post? (coming from ACF?)
Let us know.
A wise man once said:
"Have you cleared your cache?"
- You must be logged in to reply to this topic.