Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Can anyone help? ive searched google but with no luck.

currently Accounts has sub categories but no posts

/accounts/ = /billing1/ + /finance/

Billing and finance have posts but don't want them displayed in accounts

In the current loop i have

        <?php 
        // Get our extra meta
        $st_term_data = $wp_query->queried_object;
        $term_slug = get_query_var( 'term' );
        $current_term = get_term_by( 'slug', $term_slug, 'st_kb_category' );
        $term_id = $current_term->term_id;
        ?>


        <?php
        // Sub category
        $st_subcat_args = array(
          'orderby' => 'name',
          'order' => 'ASC',
          'child_of' => $term_id,
          'parent' => $term_id
        );
        $st_sub_categories = get_terms('st_kb_category', $st_subcat_args);?> 

        <?php if ($st_sub_categories) { // If the category has sub categories ?>

        <!-- .kb-category-list -->
        <div class="kb-category-list row stacked">

        <?php
        // Sub category
        $st_subcat_args = array(
          'orderby' => 'name',
          'order' => 'ASC',
          'child_of' => $term_id,
          'parent' => $term_id
        );
        $st_sub_categories = get_terms('st_kb_category', $st_subcat_args); 

        $st_sub_categories_count = count($st_sub_categories);

        foreach($st_sub_categories as $st_sub_category) { 

        if ($st_sub_categories_count == 1) {
        echo '<div class="column col-full">';
        } else {
        echo '<div class="column col-half">';   
        }

        echo '<h3><span class="count">'. $st_sub_category->count . ' Articles</span><a href="' . get_term_link($st_sub_category->slug, 'st_kb_category') . '" title="' . sprintf( __( 'View all posts in %s', 'guerilla' ), $st_sub_category->name ) . '" ' . '>' . $st_sub_category->name.' <span>&rarr;</span></a></h3>';  

        // Get posts per category
        $args = array( 
            'numberposts' => gt_get_option('st_kb_category_articles'), 
            'post_type'  => 'st_kb',
            'orderby' => 'date',
            'tax_query' => array(
                array(
                    'taxonomy' => 'st_kb_category',
                    'field' => 'slug',
                    'include_children' => false,
                    'terms' => $st_sub_category->name
                )
            )
        );
        $st_cat_posts = get_posts( $args );
        echo '<ul class="kb-article-list">';
        foreach( $st_cat_posts as $post ) : ?>
            <li><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></li>
        <?php endforeach; 
        echo '</ul></li>';
        // End Get posts per Category

        echo '</div>';        

        } ?>

        </div>
        <!-- /.kb-category-list -->

        <?php } ?>



        <?php   
        $args = array(
                        'post_type' => 'st_kb',
                        'tax_query' => array(
                                array(
                                    'taxonomy' => 'st_kb_category',
                                    'field' => 'slug',
                                    'include_children' => false,
                                    'terms' => $term_slug
                                    )
                                ),
                        'paged' => $paged
        );
        $wp_query = new WP_Query($args);
        if($wp_query->have_posts()) :  ?>

        <h3 id="category-title"><?php echo $st_term_data->name ?></h3>

        <?php while($wp_query->have_posts()) : $wp_query->the_post(); ?>

        <?php get_template_part( 'content-kb', get_post_format() );     ?>       


        <?php endwhile;  ?>



        <?php else : ?>

        <?php endif; ?>

        <?php wp_reset_postdata(); ?>

What im looking for is a way to say hey! there are no further categories run the query

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.