【问题标题】:WordPress Adding tags to loop contentWordPress 添加标签以循环内容
【发布时间】:2015-03-27 07:32:54
【问题描述】:

我现在正忙于 wordpress 循环,我试图给相应的内容添加标签,所以标题是 H 标签,摘录是 p 标签等等......

到目前为止我得到的代码是

<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>

感谢任何建议:)

【问题讨论】:

  • 抱歉代码有点碎,这里是完整的

标签: php wordpress loops


【解决方案1】:

所以你的解决方案是:

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

【讨论】:

  • 是的,抱歉还是习惯了这里的界面 :)
猜你喜欢
  • 2020-02-10
  • 2011-07-10
  • 2018-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-28
  • 2014-04-08
  • 1970-01-01
相关资源
最近更新 更多