Support

Account

Home Forums Front-end Issues Field is not showing in Front-end

Solving

Field is not showing in Front-end

  • Hi

    So I am trying to display a simple text field on the frontend of my WP theme without any results.

    I am using this into my code

    <div class="col-sm-8 col">
        <h1 class="mg-md btn-resize-mode h1-style">
         <?php the_field( 'headline' ); ?>
        </h1>
    </div>
    

    And here attached some screenshot from the backend.

    PS: I am using the ACF Theme Code Pro Plugin

    What am I doing wrong?

    Many thanks in advance!

  • I know nothing about the plugin you are using.

    Is this code being inserted inside “The Loop” or is it inserted someplace in the page outside of the loop?

  • Is placed someplace in the page outside the loop

    <!-- intro -->
    <div class="intro intro-home" id="intro-home">
    	<div class="container bloc-lg bloc-md-lg">
    		<div class="row align-items-start">
    			<div class="col-sm-4 col col-360">
    				<img />/img/lazyload-ph.png" data-src="<?php echo get_template_directory_uri(); ?>/img/placeholder-image.png" class="img-fluid mx-auto d-block lazyload" alt="placeholder image" />
    			</div>
    			<div class="col-sm-8 col">
    				<h1 class="mg-md btn-resize-mode h1-style">
    					<?php the_field( 'headline' ); ?>
    				</h1>
    			</div>
    		</div>
    	</div>
    </div>
    <!-- intro END -->
    
  • When you are outside the loop then you need to supply the post ID.

    
    $queried_object=get_queried_object();
    the_field('headline', $queried_object->ID);
    
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.