用word在word中包装div

时间:2014-02-03 11:41:29

标签: php html wordpress

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

THX!

<?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članciizove kategorije:     

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

1 个答案:

答案 0 :(得分:1)

`

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

`

我认为您的代码有标记打开和关闭问题。试试这个代码。 :)