Home › Forums › Front-end Issues › Help to show the custom fields
Hi there!
Thanks for the plugin, i really think it is very good and useful.
But i got a problem trying to show the custom fields.
I have a custom field, Barcode, with Field Name: barcode, and i try to show the information like this:
<?php the_field("barcode"); ?>
Also I tried this:
if( get_field( "barcode" ) ): ?>
<p><?php the_field( "barcode" ); ?></p>
<?php endif; ?>
The fields appears to be empty, because it never shows the information inside “Barcode”.
Also i made sure that the fields are not empty in the post.
Can anyone help?
Im using Twenty Thirteen theme in 3.7.1 WP and i place the code above inside content.php after showing the content:
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentythirteen' ) ); ?>
so it is inside the loop.
Please, help! it must be a silly thing, i hope!
thank you @jamblo but i tried also ‘ instead of “.
Still nothing 🙁
Hi @iversoncru
Can you 100% confirm that the template where you entered the code is the correct template?
If you add in some HTML, is the html rendered correctly?
Thanks
E
hello @elliot
I place the code in content.php and it looks like this:
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentythirteen' ) ); ?>
<ul>
<li>Price in £: <?php the_field("price-in-£"); ?></li>
<li>Barcode: <?php the_field("barcode"); ?></li>
<li>Place: <?php the_field("place"); ?></li>
</lu>
<?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
</div><!-- .entry-content -->
Is there a problem with it?
Hi @iversoncru
There is no problem with your snippet of code.
When you view the page source, can you see the ‘ul’ element and the 3 li’s in the HTML?
oh god,the closing ul tag was wrong T.T
Now it works as a charm!
The topic ‘Help to show the custom fields’ is closed to new replies.
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.