daily pastebin goal
70%
SHARE
TWEET

Home Loop with Network Images

gabemc Sep 7th, 2013 10 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. Template Name: Home
  4. */
  5. ?>
  6. <?php get_header() ?>
  7.    <div class="row">
  8.     <?php if ( is_user_logged_in() ) { ?>
  9.     <div class="fourcol">
  10.     <?php get_sidebar() ?>
  11.     </div>
  12.     <div class="eightcol">
  13.       <div class="page">  
  14.       <?php  
  15.       global $current_user;
  16.       get_currentuserinfo();
  17.       if ($current_user->primary_blog) {
  18.       $primary_dash_url = get_blogaddress_by_id($current_user->primary_blog) . 'wp-admin/';
  19.       $primary_url = get_blogaddress_by_id($current_user->primary_blog);
  20.       $primary_blog = get_blog_details($current_user1->primary_blog);            
  21.       }
  22.  
  23.      
  24.       ?>  
  25.       <h3>Share</h3>
  26.       <div class="welcomeText">
  27.       <h4>Hello <?php echo $current_user->display_name; ?>.
  28.       <?php switch_to_blog($current_user->primary_blog);
  29.       $terms = get_terms("trip");
  30.       $count = count($terms);
  31.       $published_posts = wp_count_posts()->publish;
  32.       if($published_posts > 0 && $count > 0){
  33.       echo("Your site <a href=\"".get_bloginfo('url')."\">".get_bloginfo('name')."</a> has ".$published_posts." posts in ".$count);
  34.       if ($count > 1){echo (" trips.");} else {echo (" trip.");}
  35.       echo("<br/><a href=\"".$primary_dash_url."post-new.php\"> Add more posts</a> or <a href=\"".$primary_dash_url."edit-tags.php?taxonomy=trip\">create a new trip.</a>");
  36.       } else {
  37.       echo("You haven't published anything yet.</h4><a href=\"".$primary_dash_url."\" class=\"getStarted bigbutton\">Get Started</a>");
  38.       }
  39.       echo("</div>");
  40.       restore_current_blog();                                                                                  
  41.       ?>      
  42.      
  43.         <div class="clear">
  44.         <h3>Explore</h3>
  45.         <h4>Random images from across the Network</h4><?php
  46.        
  47.         $myimages = network_query_posts(array('post_type'=>'attachment','posts_per_page'=>10, 'orderby'=>'rand'));
  48.         if( network_have_posts() ) {
  49.         network_the_post();
  50.         foreach($myimages as $image){
  51.         echo var_dump($image);
  52.         }
  53.         }
  54.        
  55.                
  56.         ?>
  57.         </div>
  58.       </div>
  59.    </div>
  60.   </div>  
  61.   <?php } else {
  62.   include(dirname(__FILE__).'/visitor.php'); ?>  
  63. <?php } get_footer() ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top