0

I just upgraded wordpress from v3.3 to v6.6 and PHP from 7.2 to 8.2. Once upgraded my wordpress theme just break and I have no idea how to fix this since it worked on the older version. The error shows up saying:

Fatal error: Uncaught Error: Undefined constant "thumbnail" in /var/www/noname.com/htdocs/wp-content/themes/noname/loop.php:17 Stack trace: #0 /var/www/noname.com/htdocs/wp-includes/template.php(812): require() #1 /var/www/noname.com/htdocs/wp-includes/template.php(745): load_template() #2 /var/www/noname.com/htdocs/wp-includes/general-template.php(206): locate_template() #3 /var/www/noname.com/htdocs/wp-content/themes/noname/index.php(26): get_template_part() #4 /var/www/noname.com/htdocs/wp-includes/template-loader.php(106): include('...') #5 /var/www/noname.com/htdocs/wp-blog-header.php(19): require_once('...') #6 /var/www/noname.com/htdocs/index.php(17): require('...') #7 {main} thrown in /var/www/noname.com/htdocs/wp-content/themes/noname/loop.php on line 17

loop.php

<?php
/*
Template Name: Main
*/
?>
<?php
 get_header();
?>
<h1 class="recent-heading">Latest CG Sets</h1>
<div class="recentbox">
<ul>
<?php query_posts('category_name=cg&showposts=21'); ?>
<?php while (have_posts()) : the_post(); ?>
<li> <div class="recent-title"><h2><a href="<?php the_permalink(); ?>">
          <?php the_title(); ?></a>  </h2></div>
          
<div class="recent-image"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_post_thumbnail(thumbnail); ?></a></div>
<div class="recent-time"><?php the_time('D, F jS, Y') ?></div></li>
        <?php endwhile; ?>

</ul>
</div>
</div>

Can anyone help me fix my theme since it no longer works on new version?

1 Answer 1

5

<?php the_post_thumbnail(thumbnail); ?> should be <?php the_post_thumbnail( "thumbnail" ); ?>. thumbnail is not a defined constant, and the updated version of PHP is no longer converting undefined constants into strings for you.

It appears that PHP changed the "undefined constants" message from a notice to a fatal error sometime around version 8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.