我最近在学习PHP,并使用WP和PHP玩allot。我创建了一个PHP,它获取了一些带有相同第1个标记的帖子。这需要一些教程的帮助。本教程缺少的是一条没有标签的消息。
代码如下:
<?php $tags = wp_get_post_tags($post->ID); if ($tags) { ?>
<h3>Related</h3>
<?php $first_tag = $tags[0]->term_id; $args=array(
\'tag__in\' => array($first_tag),
\'post__not_in\' => array($post->ID),
\'posts_per_page\'=>10,
\'caller_get_posts\'=>1
);?>
<ul>
<?php $my_query = new WP_Query($args); if($my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><h5><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5></li>
<?php endwhile; } wp_reset_query();
} ?>
</ul>
我认为这将是一个解决方案:<?php endwhile; else: echo(\'no tags\'); } wp_reset_query(); } ?>
但这不起作用,但老实说。。。这似乎根本不对。我知道这是很基本的,但是if-else-if-else-while-foreach。。。。有时我看不见树木,看不见森林。此外,我认为:
</ul>
放置错误。谢谢,/保罗