Home › Forums › Front-end Issues › Display only field with a content + add code inside a field › Reply To: Display only field with a content + add code inside a field
Here is a quick and basic tutorial:
Assuming your pages are using the default page template (page.php in your theme directory on the server) and you only want the field values on certain specific pages, not everywhere:
<?php
/*
Template Name: Page with custom fields
Template Post Type: page
*/
get_header();
…
…
(you can use whatever text you like for the template name)
the_content()
function, like so:
the_content();
if (get_field('proprietario')) {
?>
<strong>PROPRIETARIO:</strong> <?php the_field('proprietario'); ?><br />
<?php
}
if (get_field('indirizzo')) {
?>
<strong>INDIRIZZO:</strong> <?php the_field('indirizzo'); ?><br />
<?php
}
…
…
…
and so on and so forth.
That sounds like a lot but it’s just a one-time setup and then the only thing you need to do is select the appropriate page template whenever you want to show the fields.
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.