首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在wordpress中用div包装文章

在wordpress中用div包装文章
EN

Stack Overflow用户
提问于 2014-02-03 11:41:29
回答 1查看 360关注 0票数 0

我使用下面的代码来显示这些帖子,但是我需要用li或div包装每个帖子。目前一切都是ul。我怎么能这么做?

太棒了!

代码语言:javascript
复制
<?php global $post;
$categories = get_the_category();
foreach ($categories as $category) :
?>
<h3 class="naslovostalih">Ostali članci iz ove kategorije:</h3>
<ul class="clanciostalih">

<?php
$posts = get_posts('numberposts=15&category='. $category->term_id);
foreach($posts as $post) :
$title = get_the_title($ID);
$link = get_permalink();
printf('<a class="linkpost" title="%s" href="%s">%s</a>', $title, $link, $title);
the_post_thumbnail('thumb-232');
the_excerpt();
?>
<p class="more-link-wrapper2"><a href="<?php the_permalink(); ?>" class="read-more     button"><?php _e( 'Opširnije &raquo;', 'fearless' ); ?></a></p>
<?php endforeach; ?>

<?php endforeach; ?>

</ul>

我试过这样做: Ostaličlanci iz lanci:

代码语言:javascript
复制
<?php
$posts = get_posts('numberposts=15&category='. $category->term_id);
foreach($posts as $post) :
echo ('<div class="onepost">');
$title = get_the_title($ID);
$link = get_permalink();
printf('<a class="linkpost" title="%s" href="%s">%s</a>', $title, $link, $title);
the_post_thumbnail('thumb-232');
the_excerpt();
?>
<p class="more-link-wrapper2"><a href="<?php the_permalink(); ?>" class="read-more     button"><?php _e( 'Opširnije &raquo;', 'fearless' ); ?></a></p>
echo ('</div>');
<?php endforeach; ?>

<?php endforeach; ?>

</ul>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-03 12:15:16

`

代码语言:javascript
复制
<?php global $post;
$categories = get_the_category();
foreach ($categories as $category) :
?>
<h3 class="naslovostalih">Ostali clanci iz ove kategorije:</h3>
<ul class="clanciostalih">

<?php
$posts = get_posts('numberposts=15&category='. $category->term_id);
foreach($posts as $post) :
?>
<li>
<?php
$title = get_the_title($ID);
$link = get_permalink();
printf('<a class="linkpost" title="%s" href="%s">%s</a>', $title, $link, $title);
the_post_thumbnail('thumb-232');
the_excerpt();
?>
<p class="more-link-wrapper2"><a href="<?php the_permalink(); ?>" class="read-more     button"><?php _e( 'Opširnije &raquo;', 'fearless' ); ?></a></p>
</li>
<?php endforeach; ?>
</ul>
<?php endforeach; ?>

`

我认为您的代码有标签打开和结束的问题。试试这段代码。:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21526468

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档