Site logo

Archived topic

Content template overrides hooks

3 replies · Started by Walter on July 24, 2022

Viewing posts 1–4 of 4

First of all thank you so much for your wonderful products and support!
The issue I am having is this:

I created a generate_after_entry_title hook that contains the following ACF code to pull in my custom fields into the single post template. I set priority at 11.

<div><p>
	<?php the_field('date_and_time'); ?> <?php the_field('crew_members'); ?>
	</p>
</div>

It pulls it in nicely. However, after that I created a block content template element so that I can stylize the single post template. I added just the basic post title, post meta, and post content to the template. When I apply it, the single post template no longer recognizes the custom field hooks I generated before and they stopped showing. Is there something I'm missing? It appears the content template removes the hooks.

Hi Walter,

That would be the expected behavior. The Content Template basically overrides the default template, which included the default hooks like generate_after_entry_title.

What you can do is to:

1. Retrieve the ACF through GB Headline Blocks instead if possible.
2. Or, create a shortcode to basically output the ACF: https://docs.generatepress.com/article/creating-a-shortcode/

Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets

Hope this helps!

Thanks for the reply Fernando! I will go with the shortcode as many of my fields are not just text fields.

You’re welcome Walter!

This archived topic is closed to new replies.