Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Template Name: How To Sections
- *
- * Used to display all of the How To topics and their related posts
- *
- */
- ?>
- <?php get_header(); ?>
- <div id="content">
- <div id="page-preface" class="box">
- <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
- <div id="page-head">
- <?php if ( is_front_page() ) { ?>
- <h2><?php the_title(); ?></h2>
- <?php } else { ?>
- <h1><?php the_title(); ?></h1>
- </div>
- <?php } ?>
- <div id="page-text">
- <?php the_content(); ?>
- </div>
- <?php endwhile; endif; ?>
- <?php wp_reset_query(); ?>
- </div>
- <div id="how-to-list">
- <?php $cat = 'how-to';
- $catID = get_cat_ID($cat);
- $subcats = get_categories('parent=' . $catID);
- // Get list of subcats of How To Section
- foreach($subcats as $subcat) {
- $subcatID = get_cat_ID($cat_name);
- $cat_name = $subcat->cat_name;
- $page_name = get_page_by_title($cat_name);
- if (get_categories('child_of=' . $subcatID) != '') {
- // Check if those subcats have children
- $children_cats = get_categories('child_of=' . $subcatID);
- // Get subcat children
- echo '<div class="how-to box">';
- echo '<h2>case 1</h2>';
- echo '<h2><a href="' . get_page_link($page_name->ID) . '">' . $subcat->cat_name . '</a></h2>';
- foreach($children_cats as $child_cat) {
- $child_subcatID = get_cat_ID("'" . $child_cat_name . "'");
- $child_cat_name = $child_cat->cat_name;
- $child_page_name = get_page_by_title($child_cat_name);
- echo '<div class="how-to-child box">';
- echo '<h3><a href="' . get_page_link($child_page_name->ID) . '">' . $child_cat->cat_name . '</a></h3>';
- echo '<ul>';
- $subcat_posts = get_posts('cat=' . $child_cat->cat_ID);
- foreach($subcat_posts as $subcat_post) {
- $postID = $subcat_post->ID;
- echo '<li><a href="' . get_permalink($postID) . '">' . get_the_title($postID) . '</a></li>';
- }
- echo '</ul></div>';
- }
- echo '</div>';
- }
- else {
- if (get_categories('child_of=' . $subcatID) == '') {
- echo '<div class="how-to box">';
- echo '<h2>case 2</h2>';
- echo '<h2><a href="' . get_page_link($page_name->ID) . '">' . $subcat->cat_name . '</a></h2>';
- echo '<ul>';
- $subcat_posts = get_posts('cat=' . $subcat->cat_ID);
- foreach($subcat_posts as $subcat_post) {
- $postID = $subcat_post->ID;
- echo '<li><a href="' . get_permalink($postID) . '">' . get_the_title($postID) . '</a></li>';
- }
- echo '</ul></div>';
- }
- }
- } ?>
- </div>
- </div> <!-- #content -->
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement