【发布时间】:2021-01-06 06:51:34
【问题描述】:
我正在从 Search and Filter Pro 插件 (WordPress) 操作 results.php 文件。我还尝试显示每种自定义帖子类型的类别。但我在前端看到的只是“数组”而不是类别名称。这是我当前的代码:
if ( $query->have_posts() )
{
?>
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists('wp_pagenavi'))
{
echo "<br />";
wp_pagenavi( array( 'query' => $query ) );
}
?>
</div>
<?php
while ($query->have_posts())
{
$query->the_post();
$post_id = get_the_ID();
$post_category = get_the_category();
$description = get_field('product_description', $post_id);
?>
<div class="product-div">
<?php
if ( has_post_thumbnail() ) {
echo '<p>';
?>
<?php the_post_thumbnail("small");?>
<?php
echo '</p>';
}
?>
<h3><?php echo $post_category; ?></h3>
<h2><?php the_title(); ?></h2>
<?php echo $description;?>
</div>
<?php
}
?>
<?php
}
else
{
echo "No Results Found";
}
?>
我做错了什么?
【问题讨论】: