我使用"简单帖子列表"-wordpress插件,它将所有帖子输出为一个长列表-如何设置输出样式,比如4列,并确定字体大小(据我所知,这在php中是不可能的(?看起来不太难,但我对php一无所知。。。所以请告诉我在哪里改什么。。。
function posts_list () {
$output='<ul>';
$posts = get_posts('numberposts=-1');
foreach($posts as $post){
$permalink = get_permalink( $post->ID );
$output.= '<li>' . '<a href="' . $permalink . '">' . $post->post_title . '</a></li>';
}
$output.='</ul>';
return $output;
}
function pages_list () {
$output='<ul>';
$pages = get_pages();
foreach($pages as $page){
$permalink = get_permalink( $page->ID );
$output.= '<li>' . '<a href="' . $permalink . '">' . $page->post_title . '</a></li>';
}
$output.='</ul>';
return $output;
}
add_shortcode('posts','posts_list');
add_shortcode('pages','pages_list');
?>
非常感谢!Michael
一个简单的仅使用CSS的方法可以将列表元素向左浮动,并使它们的总宽度为25%。也许可以加一些填充物,这样它们就不会碰到了。因此,宽度为23%,左右填充为1%,总共占25%。
ul{list-style-type: none;}
li{float: left; width: 23%; padding: 0 1%;}
演示