ACF Does Not Show

Hello,
I added ACF Pro and programmed it to show on the Fullwidth template. It did not show. 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: TEST ?> <?php get_header(); ?>
  <?php while ( have_posts() ) : the_post(); ?>
    <?php x_get_view( 'integrity', 'content', 'page' ); ?>
    <?php x_get_view( 'global', '_comments-template' ); ?>
  <?php endwhile; ?>

</div>

<?php get_sidebar(); ?>

The published changed do not show Can you help?

Thanks,
LF

Hi,

Can you provide us the url of the page where we can see the issue.

The code you provided does not include anything that would show acf, you need to add something like this.

<p><?php the_field('about_author'); ?></p>

We actually have a guide on how to use this plugin in xtheme. Please refer to the link below

Thanks

Thanks, I’ll have a look at the guide and let you know. The url is: http://r73.dd4.myftpupload.com/test/

Hi there,

I tried checking the URL you have indicated but it goes to a 404 page.

Please let us know how it goes.

Thank you.

Okay, I’ve added the new code to the page template attached here. It still does not show at http://r73.dd4.myftpupload.com/test/, use pw “test”
Please help,
LF

Hi,

I checked your code and it doesn’t include anything that would output your fields thus it does not show.

Please try to use echo - https://www.w3schools.com/php/php_echo_print.asp

For example

$intro_title = $fields["intro_title"];
echo intro_title;

Hope that helps.

No, it really doesn’t help. The link simply shows what echo is, not how to use it with the X theme I purchased and it’s included ACF. I added the “echo intro_title;” etc to my code and it doesn’t look any better. Other problems include:

  • The content doesn’t show correctly, ie “intro_title” instead of the text I added in the field “JOHN SMITH”
  • The content is not inside the white part of the page.
  • The background image of the page does not show.
  • The ACF plugin will not update due to no license.
    Please help ASAP as the client needs to show this page soon.
    LF

Hi,

To make it easier I would recommend you to use cornerstone builder instead of creating a custom template to output your fields.

We’ve included a basic ACF Pro integration with Cornerstone which allows you to use a shortcode within your pages and posts created with Cornerstone to automatically pull through the value of your ACF Pro custom field without having to modify template files.

You’d use:

{{acf:field_name}}

Within your Cornerstone content where field_name is the name of your field as shown in the ACF Pro field edit screen. Please note, this is a basic integration and will only support text-based fields. For example, it won’t output a gallery. Also, use the WYSIWYG type field with caution - WordPress’s visual editor automatically adds tags, which can break element markup causing display issues.

Please provide wordpress admin login in Secure Note so we can assist you better with this issue.

Thanks

I did as instructed on the Agent page, and it just made things worse. I’ve sent you login credentials so have a look as soon as you can and let’s get this figured out.
Thanks,
Lilia

Hi Lilia,

Sorry if it does not work. There was a typo error in the code. You should be using this:

<?php

// =============================================================================
// TEMPLATE NAME: TEST

?>

<?php get_header(); ?>

  <div class="x-container max width offset">
    <div class="<?php x_main_content_class(); ?> mao ni" role="main">

      <?php while ( have_posts() ) : the_post(); ?>
        <?php x_get_view( 'integrity', 'content', 'page' ); 		

	$fields = get_fields();
	//$banner = $fields ["banner"]; echo banner;
	$intro_title = $fields ["intro_title"];
	echo $intro_title;

	$subtitle = $fields ["intro_subtitle"]; 
	echo $intro_subtitle;
	
	$hide_title = $fields ["hide_title"];
	echo $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_sidebar(); ?>

  </div>

Because what you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After setting up and activation the child theme, place test.php in the child theme’s folder instead.

You might probably wonder why the output is outside the page entry wrap. That is because the page entry wrap is in this line: <?php x_get_view( 'integrity', 'content', 'page' );. What you will do is to update your contents using this code instead:

<?php

// =============================================================================
// TEMPLATE NAME: TEST

?>

<?php get_header(); ?>

  <div class="x-container max width offset">
    <div class="<?php x_main_content_class(); ?> mao ni" role="main">

      <?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"]; echo banner;
				$intro_title = $fields ["intro_title"];
				echo $intro_title;

				$subtitle = $fields ["intro_subtitle"]; 
				echo $intro_subtitle;
				
				$hide_title = $fields ["hide_title"];
				echo $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' ];
			?>


		  </div>
		</article> 		



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

    </div>

    <?php get_sidebar(); ?>

  </div>

We would loved to know if this has work for you. Thank you.

Thanks for sending this. It worked a little. “John Smith” is showing but none of my other content is, including the bg image.
Can you help?
LF

Hello Lilia,

I’ve only fixed the display of the title, sub title and hide title variable:

				$intro_title = $fields ["intro_title"];
				echo $intro_title;

				$subtitle = $fields ["intro_subtitle"]; 
				echo $intro_subtitle;
				
				$hide_title = $fields ["hide_title"];
				echo $hide_title;

Please put echo $variable_name; if you want to display the variable.

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