如何纠正此错误?我开始通过查询调用产品,但我遇到了这个问题--我认为问题在于打开和关闭PHP标记,但我无法修复它
致命错误:未定义错误:调用C:\xampp\htdocs\gptec\fa\wp-content\themes\gptec_wptheme\index.php:102堆栈跟踪中的未定义方法WC_Product_Simple::have_posts():#0 C:\xampp\htdocs\gptec\fa\wp-includes\template-loader.php(74):include() #1 C:\xampp\htdocs\gptec\fa\wp-blog-header.php(19):require_once('C:\xampp\htdocs )。.‘) #2 C:\xampp\htdocs\gptec\fa\index.php(17):要求(’C:\xampp\htdocs.‘) #3 {main}抛入第102行的C:\xampp\htdocs\gptec\fa\index.php中
我的密码:
<div class="row">
<?php
$product=new WP_Query(
array(
'post_type'=>'product',
'post_per_page'=>6
)
);
?>
<?php
if ($product->have_posts())
{
while ($product->have_posts())
$product->the_post();
{ ?>
<div class="col-lg-3 p-2 m-2" >
<div class="card card-4 text-center cls">
<?php the_post_thumbnail(); ?>
<div class="clearfix"></div>
<span class="description-text pb-1 mb-1"><?php the_title()?></span>
<div class="clearfix"></div>
<a href="<?php the_permalink() ?>">
<button type="button" class="btn btn-outline-success slideright p-2 m-2">مشاهده محصول</button>
</a>
</div>
</div>
<?php }}?> <!--Card-->
</div>发布于 2018-12-07 16:10:00
$product在伍尔商业是全球性的。所以你犯了错误。
所以使用其他变量来代替$product
https://stackoverflow.com/questions/53671325
复制相似问题