Site logo

Archived topic

Outputting Advanced Custom Fields

12 replies · Started by JUDE on September 17, 2020

Viewing posts 1–13 of 13

I know there are lots of posts already about ACF and Generatepress, but I've not found one that answers my question. So, apologies if I'm going over ground that's already been covered.

I have generated an ACF for posts in particular categories. In the admin section that's fine - I can input the info I need.

My issue is how to output them at the other end. Usually I know this means editing the actual WP templates. Is there a different way to do this in Generatepress - I've been looking at Elements, and Hooks, and pasting in things like
{{custom_field.film-title}}
{{custom_field.film-director}}
but nothing displays.

Do I have to edit the actual templates, or can Generatepress do some of the heavy lifting here?

Hi there,

If I understand this correctly, the hook element should be what you are looking for:
https://docs.generatepress.com/article/hooks-element-overview/

You can add something like this to output it and make sure to check to execute PHP:

<?php
$custom_field = get_post_meta( get_the_ID(), 'film-title', true );

echo $custom_field;
?>

Okay, thanks, that looks like a proper bit of code!

So - where do I generate the hook? Is it generate_after_main_content? Or somewhere else?

In the main body of the post.

Based on that it'd be the generate_after_content hook.

I'm not seeing it though.

It's not exactly a sing;e post. I want it to output to all posts in a certain category.

Execute Shortcodes and Execute PHP are also both checked.

I am using the display rules.
It's probably something really basic I'm getting wrong.
I've included all the relevant links in the Private Information section.

Oh goodness, that was it! Thank you.

No problem :)

This archived topic is closed to new replies.