PHP Fatal error

Hi, Apparently something in my child theme is causing a PHP Fatal error. Not sure if I should include the error message in this post, but I can provide it if you like.

Site: travelstudies.org
X theme: 6.0.04
Wordpress: 4.9.5

Thanks for your help.

Hello @Hudsonpilot,

Thanks for asking. Hope you’re having a great day. :slight_smile:

Upon checking the website in dev tools, I see that you are using the latest version of X Theme and Cornerstone (also mentioned in the ticket). In frond end of the website I don’t see any error message message. In that case it seems that the error message is showing up in backend. Can you please share the error message that is showing up? That way we can share solution for the same.

Thanks.

These errors appear in php_errorlog

[06-Apr-2018 14:27:32 UTC] PHP Fatal error: Uncaught Error: Call to undefined function get_field() in /home/trave130/public_html/wp-content/themes/x-child/framework/views/ethos/wp-single.php:21
Stack trace:
#0 /home/trave130/public_html/wp-content/themes/x/framework/functions/global/view-routing.php(182): include()
#1 /home/trave130/public_html/wp-content/themes/x/framework/functions/global/view-routing.php(55): X_View_Router::render(’/home/trave130/…’, Array, true)
#2 /home/trave130/public_html/wp-content/themes/x/single.php(17): x_get_view(‘ethos’, ‘wp’, ‘single’)
#3 /home/trave130/public_html/wp-includes/template-loader.php(74): include(’/home/trave130/…’)
#4 /home/trave130/public_html/wp-blog-header.php(19): require_once(’/home/trave130/…’)
#5 /home/trave130/public_html/index.php(17): require(’/home/trave130/…’)
#6 {main}
thrown in /home/trave130/public_html/wp-content/themes/x-child/framework/views/ethos/wp-single.php on line 21

Hi There,

Thank you for the information provided. It seems that you’re trying to output a custom field in that template using ACF Pro which cause this error. You can also try the_field() function and see if that helps (https://www.advancedcustomfields.com/resources/the_field/).

If that doesn’t help, you need to check few things to isolate the issue.

  • Check your PHP version and make sure to use something like PHP v5.6.x or later to avoid incompatibility issues.
  • Switch back to your parent X theme and test your site to see if you’re getting this error.
  • Make sure that you’re fully updated including X theme and plugins. You can check the version numbers from the following link (https://theme.co/apex/forum/t/troubleshooting-version-compatibility/195)

Let us know how it goes.
Thanks!

Thanks for pin pointing the problem. I must have configured the wp-single.php file in the child theme incorrectly. Here’s what I’m trying to do:

At the end of a post, I have a line for the source of the featured image that looks like this:

(Image: [image_title]; Source: [image_photographer])

The image_photographer is a link to [photographer_url]

Here’s how I modified the wp-single.php file:

// =============================================================================
// VIEWS/ETHOS/WP-SINetLE.PHP
// -----------------------------------------------------------------------------
// Single post output for Ethos.
// =============================================================================

$fullwidth = get_post_meta( get_the_ID(), ‘_x_post_layout’, true );

?>

<?php get_header(); ?>
    <?php while ( have_posts() ) : the_post(); ?>
      <?php x_get_view( 'ethos', 'content', get_post_format() ); ?><p></p>
      <?php if( $field = get_field('image_photographer') ): ?>

(Image: <?php the_field('image_title') ?>; Source: <?php the_field('image_photographer') ?>)

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

  <?php if ( $fullwidth != 'on' ) : ?>
    <?php get_sidebar(); ?>
  <?php endif; ?>

</div>
<?php get_footer(); ?>

Can you see from this what I did wrong?

Hello There,

The code is correct. The error: Call to undefined function get_field() may have occured because ACF pro is not installed or activated. Please make sure that ACF plugin is active. This is only only logical explanation why a fatal error may occur in the site.

Please let us know how it goes.

Thanks for reviewing the code. Now that you say the only logical explanation is that ACF pro is not installed, I’m going to guess that the error message was generated during the brief time that the plugin was uninstalled while I was doing an update. The error is not recurring, anyway. i would never have even noticed the error had I not been going through error logs to deal with another problem. Thanks again for your help.

You’re most welcome! Yes, doing multiple things at the same time would trigger that since it’s single installation.

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