Home Forums Front-end Issues Help to show the custom fields


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">&rarr;</span>', 'twentythirteen' ) ); ?>
    so it is inside the loop.

    Please, help! it must be a silly thing, i hope!

  • Use ‘ instead of “:

    <?php the_field('barcode'); ?>

    Any good?

  • 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?


  • 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">&rarr;</span>', 'twentythirteen' ) ); ?>
    			<li>Price in £: <?php the_field("price-in-£"); ?></li>
    			<li>Barcode: <?php the_field("barcode"); ?></li>
    			<li>Place: <?php the_field("place"); ?></li>
    		<?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!

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Help to show the custom fields’ is closed to new replies.