1

我遇到以下情况:

这段代码:

<ul class="products columns-4 glassbyhan-products">
<?php
while ( have_posts() ): the_post();
global $product;    
?>
    <li class="glassbyhan-product">
        <a href="<?php echo get_permalink(); ?>">
            <span class="et_shop_image" style="background-image: url('<?php  echo the_post_thumbnail_url('woocommerce_thumbnail'); ?>')">
                <?php   if ( $product->is_on_sale() ) : ?>
                    <?php echo apply_filters( 'woocommerce_sale_flash', '<span class="onsale">' . esc_html__( 'Sale!', 'woocommerce' ) . '</span>',  $product ); ?>
                <?php endif;?>
            </span>
            <strong><?php echo the_title(); ?></strong><br/>
            <?php echo $product->get_price_html();?>
        </a>
    </li>
<?php
endwhile;
wp_reset_query();
?>
在一台服务器(测试服务器)上工作,但在另一台服务器(实时服务器 - 物理另一台服务器)上发生以下错误:

[Thu Nov 04 17:50:01.638110 2021] [proxy_fcgi:error] [pid 1520496:tid 140160309864192] [client 80.57.194.158:58615] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Call to a member function is_on_sale() on null in /inc/template/producten.php:16
Stack trace:
#0 /facetwp-org/includes/class-renderer.php(544) : eval()'d code(2): include()
#1 /facetwp-org/includes/class-renderer.php(544): eval()
#2 /facetwp-org/includes/class-renderer.php(218): FacetWP_Renderer->get_template_html()
#3 /plugins/facetwp-org/includes/class-display.php(77): FacetWP_Renderer->render()
#4 /wp-includes/shortcodes.php(356): FacetWP_Display->shortcode()
#5 [internal function]: do_shortcode_tag()
#6 

它是一个 wordpress 站点(测试服务器 = plesk php 7.4)实时服务器 = directadmin php 7.4 - 不知道是否需要此信息。

4

0 回答 0