Hi,
I have created custom field for pages, and i created home page. When i am trying to fetch the field value in index.php using the below code . But nothing is displaying in front end. Please help me.
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme and one
* of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query,
* e.g., it puts together the home page when no home.php file exists.
*
* @link http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
get_header(); ?>
<div id=”main-content” class=”main-content”>
<div id=”primary” class=”content-area”>
<div id=”content” class=”site-content” role=”main”>
<?php the_field(“page_intro_text”); ?>
</div><!– #content –>
</div><!– #primary –>
</div><!– #main-content –>
<?php
get_sidebar();
get_footer();
Thanks.
Elliot answered a similar question here. In order to call a field while on index.php, you need to add the page_ID like this: <?php the_field('page_intro_text', 15); ?>
where the number ’15’ is the value of page_ID for the page that has the field 'page_intro_text'
.