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.

Alright, so problem I have is my client has 8 WP sites in a network. 1 specific site they want additional posts from another category to display other then child posts of thew News category. I have thought of a few methods.. manually including each category id, but that would be 30+ every year a new category could be made so this wouldn't work. Is it possible to include in my loop adding in posts that tagged with a specific term?

                <?php

                if( $blog_id == '1' || $blog_id == '2' || $blog_id == '3' || $blog_id == '4' || $blog_id == '5' || $blog_id == '6' || $blog_id == '7' || $blog_id == '8' || $blog_id == '9' || $blog_id == '10' ) { // Custom if statement that states if equal to blog id, then display the content below.

                    global $switched;
                    switch_to_blog(1); 

                    //for each child of category 7 (news), show title of posts
                    $cat_args=array('child_of' => 7, 'orderby' => 'name', 'exclude' => '53', 'order' => 'DESC');
                    $categories=get_categories($cat_args);
                    foreach($categories as $category) {
                    $args=array('showposts' => -1, 'category__in' => array($category->term_id), 'caller_get_posts'=>1);
                    $posts=get_posts($args);

                      if ($posts) {
                        echo '<h3>' . $category->name.'</h3> ';
                        foreach($posts as $post) {
                          setup_postdata($post); ?>
                            <ul>
                                <li>
                                   <?php $content = get_the_content();
                                   $output = ( strlen($content) < 380 ) ? $content : get_the_excerpt(); ?>
                                  <!--<a href='<?php echo $content; ?>'><?php echo $output; ?></a>-->
                                  <?php echo $output; ?>
                                </li>
                            </ul>
                         <?php
                        } // foreach($posts
                      } // if ($posts
                    } // foreach($categories

                    restore_current_blog(); // Bring back the current blog you are visiting on the network

                }  // end of if network statement

            ?>

I need to include category id 88 on top of the child_of 7 or use a tag of "additional" to shwo the children of 7 and the additional posts (in chronological order like they are now).

Thanks!

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.