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
Yeah, you mixed something up in your template (get_header()
twice, a missing closing bracket etc.). Change it to this right here:
<?php
/*
Template Name: Page with custom fields
Template Post Type: ACF
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'template-parts/content', 'page' ); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>
<?php
endwhile; // end of the loop.
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
}
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
The file should be in your theme folder. See if you can select the template now. Here is an explanation on how to create a page template, just for your information (or to compare whether you’ve done everything correctly): https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-page-templates-for-global-use
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.