ACF Doesn't Show on Template

Hello,
I added ACF Pro and programmed it to show on the Regional Developer template. It did not show here: http://r73.dd4.myftpupload.com/test-2/. The 17 fields I added do show on the page creator, but do not show when published. I then created my own page template as shown here:

<?php /** * Template Name: Regional Developer Template */ ?> <?php get_header(); ?>
  <?php while ( have_posts() ) : the_post(); ?>
    
    <?php $disable_page_title = get_post_meta( get_the_ID(), '_x_entry_disable_page_title', true ); ?>

	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<?php if ( has_post_thumbnail() ) : ?>
	  <div class="entry-featured">
	    <?php x_featured_image(); ?>
	  </div>
	<?php endif; ?>
	  <div class="entry-wrap">
	    <?php if ( is_singular() ) : ?>
	      <?php if ( $disable_page_title != 'on' ) : ?>
	      <header class="entry-header">
	        <h1 class="entry-title"><?php the_title(); ?></h1>
	      </header>
	      <?php endif; ?>
	    <?php else : ?>
	    <header class="entry-header">
	      <h2 class="entry-title">
	        <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php x_the_alternate_title(); ?></a>
	      </h2>
	    </header>
	    <?php endif; ?>
	    <?php x_get_view( 'global', '_content' ); ?>

		<?php

$fields = get_fields();
//$banner = $fields [“banner”];
$intro_title = $fields [“intro_title”];
echo $intro_title;
$subtitle = $fields [“intro_subtitle”];
$hide_title = $fields [“hide_title”];

$rd_img_id = $fields ["rd_image"];
$rd_img_url = wp_get_attachment_image_src($rd_img_id, 'large', false);
$rd_img = $rd_img_url[0];


$rd_secton_heading = $fields ["subtitle"];
$rd_areas = $fields ["areas_of_high_development"];
$rd_content = $fields ["content_area"];

$rd_bottom_content = $fields ["bottom_content"];


$rd_contact_img_id = $fields ["contact_image"];
$rd_contact_img_url = wp_get_attachment_image_src($rd_contact_img_id, 'large', false);
$rd_contact_img = $rd_contact_img_url[0];

$rd_contact_name = $fields ["contact_name"];
$rd_contact_phone = $fields ["contact_phone_number"];

		$contact_form = $fields["contact_form"];
		$form_object = $contact_form;
		gravity_form_enqueue_scripts($form_object['id'], true);

$options = get_fields(‘options’);
$why_title = $options [“why_honest_title”];
$why_content = $options [“why_honest_content”];

$socials = $fields[ ‘socials’ ];
?>

    <?php x_get_view( 'global', '_comments-template' ); ?>
  <?php endwhile; ?>

</div>

<?php get_footer(); ?>

Please help,
LF

Hello @liliaf,

Thanks for writing in!

This example shows how to check if a value exists for a field and display it.

$value = get_field( "text_field" );

if( $value ) {

    echo $value;

} else {

    echo 'empty';

}

To be able to display the custom fields added with ACF Pro, you will need this line:

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

In your case, if you want to display a particular field, you will have to do it like this:

$socials = $fields[ 'socials' ];
echo $socials;

Or simply this by having this line:

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

Please refer to the documentation for the proper way to display the fields: https://theme.co/apex/forum/t/integrated-plugins-acf-pro/49
https://www.advancedcustomfields.com/resources/get_field/

Hello,
I did as you asked but the fields still do not show properly. I would like for them to look like: http://r73.dd4.myftpupload.com/region/
Please advise,
LF

Hi @liliaf,

The code was just to display the field value.
To style it, you will need to wrap it with html tags with class attribute then target it in your css code.

eg.

html code

<h2 class="intro_title"><?php the_field('intro_title'); ?></h2>
<h3 class="intro_subtitle"><?php the_field('intro_subtitle'); ?></h3>

css

.intro_title {
    font-size:30px;
}

.intro_subtitle {
    font-size:25px;
}

Please note that ACF is also integrated into cornerstone. You can display the field value using the following pattern

{{acf:field_name}}

I suggest you use cornerstone instead of creating templates, that way you can easily change layout and style the elements.

Kindly review the link below for more information

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.