感谢您的回复!但是,更改后没有相关的帖子显示。有什么想法吗?
以下是我将代码更改为的内容:
if(!function_exists(\'solstice_related_post\')) {
函数solstice\\u related\\u post(){全局$post;$tags=wp\\u get\\u post\\u terms($post->ID);
if(!empty($tags) && is_array($tags)):
$simlar_tag = $tags[0]->term_id;
?>
<div class="related-posts">
<h6><?php esc_html_e(\'YOU MIGHT ALSO LIKE\', \'solstice-theme\'); ?></h6>
<div class="row">
<?php
$args = array(
\'category__in\' => array($simlar_tag),
\'post__not_in\' => array($post->ID),
\'posts_per_page\' => 3,
\'meta_query\' => array(array(\'key\' => \'_thumbnail_id\', \'compare\' => \'EXISTS\')),
\'ignore_sticky_posts\' => 1,
)$re\\u query=新的WP\\u查询($args);while($re\\u query->have\\u posts()):$re\\u query->the\\u post();?>>
“>
”>