WordPress.org

Ready to get started?Download WordPress

Forums

Create "the loop" within multisite, ordinary lineup of posts (1 post)

  1. jdqt
    Member
    Posted 1 year ago #

    Hi

    I've been trying out tons of plugins and solutions to fixing the loop. I hope this is the right place to post in, I think its related to the multisite.

    Background about the site:
    1 - I run WordPress 3.5.2
    2 - Multisite enabled
    3 - StyleMag theme

    I want the mainsite to work as a portal for all the articles and also the blogs, with that I mean that I want the header and footer to be the exact same all over the website. I want to have it easy administrated so that I dont have to edit a menu or header for all the sites. So that thing I have solved with switch_blog() for the moment, working OK, but not totaly statisfied.

    So now Im trying to fetch an ordinary the loop for one of the blogs I've created in the network. I have taken the single-default.php page and tried to edit it to fetch all the posts from all categories. But not getting it to work. I think it might have something with the switch_blog() function to do, but Im not sure.

    So what I've done is i created a copy of single-default.php and renamed it to template-blogindex.php, put in the template name at the top as Blogg Index and then created a new page and given it the template, "Blogg Index".

    I really dont know why it doesnt fetch any posts.

    For now the code looks like this:

    <?php
    /*
    Template Name: Blogg Index
    */
    ?>
    
    <?php global $data; ?>
    <?php $categories = get_categories( $args ); ?>
    <?php get_header(); ?>
    
    <!-- BEGIN #main-content -->
    <div <?php echo sidebar_position('primary-content'); ?>>
    
    	<h1 class="page-title">
    		<?php the_category(', '); ?>
    	</h1>
    
    	<!-- BEGIN .page-content -->
    	<?php switch_to_blog(2); ?>
    	<div <?php post_class("page-content"); ?>>
    
    		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    			<div class="no-image"></div>
    
    		<h2 class="article-title">
    			<?php the_title(); ?>
    			<span class="article-meta">
    				<span class="article-date"><?php the_time('F j, Y'); ?></span><span class="article-category"><?php the_category(', '); ?></span><span class="article-comments"><?php comments_popup_link(
    					__( '0 Comments', 'qns' ),
    					__( '1 Comment', 'qns' ),
    					__( '% Comment', 'qns' ),
    					__( '', 'qns' ),
    					__( '<span class="comments-off">Off</span>','qns')
    				); ?></span>
    			</span>
    		</h2>
    
    		<?php the_content(); ?>
    
    		<p class="post-tags"><?php the_tags( __('Tags: ','qns'), ', ', '' ); ?></p>
    
    		<?php
    			wp_link_pages( array(
    				'before' => '<div class="page-pagination">',
    				'after' => '</div>',
    				'link_before' => '<span class="page">',
    				'link_after' => '</span>'
    			) );
    		?>
    
    		<?php if( $data['display_sharing_options'] ) { ?>
    
    			<div class="article-social-links">
    				<ul class="clearfix">
    					<li class="tweet-link"><a target="_blank" href="http://twitter.com/share?text=<?php the_title(); ?>"><?php _e('Tweet this article','qns'); ?></a></li>
    					<li class="facebook-link"><a target="_blank" href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>/&t=<?php the_title(); ?>"><?php _e('Share on Facebook','qns'); ?></a></li>
    					<li class="pinterest-link"><a target="_blank" href="http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php echo $src[0]; ?>&description=<?php the_title();?>"><?php _e('Pin on Pinterest','qns'); ?></a></li>
    				</ul>
    			</div>
    
    		<?php } ?>
    
                                    <?php endwhile; else: ?>
                                    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
                                    <?php endif; ?>
    		<?php restore_current_blog(); ?>
    	<!-- END .page-content -->
    	</div>
    
    <!-- BEGIN #main-content -->
    </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic