Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 如何将标记附加为类_Wordpress - Fatal编程技术网

Wordpress 如何将标记附加为类

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'); ?> <

在遍历所有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 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属性中