你这里有很多问题。首先,您要求Tag\\u slug\\uu in,但提供了一个标题,其次,Tag\\u slug\\uu in接受一个数组(我不确定它是否适用于字符串)。这两个问题都会导致问题,因为标题不是段塞,数组不是字符串。。也许就用“标签”?但如果页面标题不等于一个slug呢?那么您就有一个错误,没有错误消息来说明发生了什么。(我相信这就是这里发生的事情。)或者您有多个特色帖子?
您有2个自定义查询,但没有在其中任何一个中重置post数据。
我要求查看其余的代码,因为我不知道这是什么类型的页面,与args中的“get\\u the\\u title()”引用相关。这是存档、模板、类别或分类页面等。
下面是一个代码示例。我已经从您的两个查询中注释掉了您的tag\\u slug\\uu。我已经添加了post重置,我已经为您添加了实际返回的内容。
<?php
// Attempting to show featured first: the array pulls one post from the \'Featured\' category with the relevant tag. This works correctly
$my_query = new WP_Query(array(
\'category_name\' => \'featured\',
\'posts_per_page\' => 1,
//\'tag_slug__in\' => get_the_title()
)
);
while ( $my_query->have_posts() ) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<!-- Code to display featured post with relevant formatting goes here -->
echo \'My Featured Post: \'. get_the_title().\'<br><hr><br>\';
<?php
// This ends the first loop
endwhile;
wp_reset_postdata();?>
<?php
// The query for standard posts: this is supposed to check posts for the relevant tag. This loop worked correctly before I added the loop for featured posts
$the_query = new WP_Query(array(
//\'tag_slug__in\' => get_the_title(),
\'posts_per_page\' => -1
)
);
// The loop to display these posts according to the query
if( $the_query->have_posts() ):
while( $the_query->have_posts() ): $the_query->the_post();
// This line is from the Codex, and is supposed to prevent duplication of the featured post. I\'m unsure if this is implemented correctly?
if ( $post->ID == $do_not_duplicate ) continue; ?>
<!-- Formatting for regular posts -->
echo \'Not a Featured Post: \'. get_the_title().\'<br>\';
<?php
// Ending second loop
endwhile;
wp_reset_postdata();
endif;
?>