Wordpress 如何将标记附加为类
在遍历所有post的for循环中,如何将post的所有标记作为div类的一部分追加Wordpress 如何将标记附加为类,wordpress,Wordpress,在遍历所有post的for循环中,如何将post的所有标记作为div类的一部分追加 <?php $page_name = $wp_query->post->post_name; query_posts('category_name='. $page_name .'&posts_per_page=-1&orderby=date&order=DESC'); ?> <
<?php
$page_name = $wp_query->post->post_name;
query_posts('category_name='. $page_name .'&posts_per_page=-1&orderby=date&order=DESC');
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="galleryItem ">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<div class="titlePlate">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?></a></h3>
</div><!--END titlePlate-->
</div><!--END galleryItem-->
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?><?php wp_reset_query(); ?>
抱歉,没有符合您标准的帖子
您可以使用以下代码打印帖子的所有标签:
<?php
$postid = get_the_ID();
$tags = wp_get_post_tags($postid);
foreach ($tags as $tag) {
echo $tag->name . " "; //put a space to seperate every tag.
}
?>
这些代码将显示post的所有标记,然后您可以将其插入到所需的确切Div的class属性中