<?php
$tag__in
=
array
();
$tabs
= get_the_tags(
$post
->ID);
if
(
is_array
(
$tabs
) ) {
foreach
(
$tabs
as
$tag
) {
$tag__in
[] =
$tag
->term_id;
}
}
$query_data
=
array
(
'posts_per_page'
=> 6,
'tag__in'
=>
$tag__in
,
'post__not_in'
=>
array
(
$post
->ID)
);
$post_list
=
new
WP_Query(
$query_data
);
?>
<ul>
<?php
while
(
$post_list
->have_posts() ) {
$post_list
->the_post();
global
$post
;
?>
<li><a href=
"<?php the_permalink() ?>"
rel=
"bookmark"
title=
"Permanent Link to <?php the_title_attribute(); ?>"
><?php the_title(); ?></a> (<?php
echo
(
$post
->comment_count); ?>)</li>
<?php } ?>
</ul>
<?php wp_reset_query(); ?>
這是標籤功能為依據的相關文章,會根據目前的文章自動輸入適當的標籤,同時會規避掉自己這一篇文章。