Tag: WordPress/Tips
function list_posts($parent) { echo "<ul>"; $args = array('category' => $parent, 'post_type' => 'post'); global $enable_custom_order; $enable_custom_order = TRUE; $posts = get_posts( $args ); $enable_custom_order = FALSE; foreach ($posts as $post) { echo '<li><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a>'; } echo "</ul>"; } function list_category($parent) { echo "<ul>"; $args = array( 'parent' => $parent ); $categories = get_categories( $args ); foreach ( $categories as $category ) { if ($category->cat_ID == 32) { //Swift情報はパス continue; } echo '<li><a href="' . get_category_link( $category->term_id ) . '">' . $category->name . '</a><br/>'; if ($parent == 0) { // echo "#####" . $category->cat_ID; list_category($category->cat_ID); } else { list_posts($category->cat_ID); } } echo "</ul>"; } list_category(0);