我试图在主页上列出我的帖子的类别,每个帖子都在它们下面。我真的不知道该怎么做。
我想要的例子。
1类
1号岗位-2号岗位-3号岗位-4号岗位第2类
1号岗位-2号岗位-3号岗位-4号岗位第3类
1号岗位-2号岗位-3号岗位-4号岗位编辑2:
让这个工作。
<?php
$args = array(
\'orderby\' => \'name\',
\'order\' => \'ASC\'
);
$categories = get_categories($args);
foreach( $categories as $category ) {
echo \'<h1><a href="\' . get_category_link( $category->term_id ) . \'" title="\' . sprintf( __( "View all posts in %s" ), $category->name ) . \'" \' . \'>\' . $category->name.\'</a> </h1>\';
global $post;
$args = array(
\'posts_per_page\' => 4,
\'offset\'=> 0,
\'category\' => $category->term_id
);
$posts = get_posts( $args );
foreach( $posts as $post ) {
echo \'
<a href="\' . $post->guid . \'" title="\' . $post->post_title . \'">
\' . get_the_post_thumbnail($page->ID, \'small\') . \'
</a>
\';
}
}
?>