douhao123457 2015-03-27 07:32
浏览 58

WordPress添加标签以循环内容

I am wrapping my head on wordpress loop at the moment, im trying to give tags to the respective content, so an H tag to the title, an p tag to the excerpt and so on...

The code i got so far is

<div id="<?php echo $page_id; ?>" class="container"><!-- begin container -->
<div id="postovi" style="display:none;">
<?php $custom_loop = new 
WP_Query('showposts=5&category_name=Zanimljivosti&orderby=rand');
if (  $custom_loop->have_posts() ) :    echo '<ul>';    while ( $custom_loop->have_posts() ) : $custom_loop->the_post();        echo '<li><a href="' . get_permalink() . '">' . get_the_title() . get_the_post_thumbnail($loop->post->ID, 'shop_catalog') . get_the_excerpt();'</a></li>';      endwhile;   wp_reset_query();   echo '</ul>';endif;?>       </div>

any suggestions apreciated :)

  • 写回答

1条回答 默认 最新

  • dounue1965 2015-03-27 10:02
    关注

    So your solution is :

            <?php
            $custom_loop = new WP_Query('showposts=5&category_name=Zanimljivosti&orderby=rand');
            if ( $custom_loop->have_posts() ) : 
            echo '<ul>';
            while ( $custom_loop->have_posts() ) :
            $custom_loop->the_post();    echo '<li><h2><a href="' . get_permalink() . '">' . get_the_title();
            echo '</h2>' . get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); 
            echo'<p>' . get_the_excerpt();'</p></a></li>'; 
            endwhile;   wp_reset_query();   
            echo '</ul>';endif;
            ?> 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器