• Resolved caefavsvs

    (@awa4000)


    This should be a really easy fix…

    I created a custom page template using the code provided at under the ‘A Page of Posts’ heading. I succeeded in my goal of creating a page that only displays posts from one category but now the content is not floating next to the sidebar but pushed below it.

    The URL is .
    I am using the twenty-eleven theme.
    The posts are published under the default post type.
    And here is the code I copied and amended:

    <?php
    /*
    Template Name: Page Of Posts
    */
    
    /* if you are not using this in a child of Twenty Eleven,
    *  you need to replicate the html structure of your own theme.
    */
    
    get_header();
    get_sidebar();
    ?>
    <div id="primary">
      <div id="content" role="main">
    
      <?php
      /* the_post will retrieve the content of the new page you
      *  create to list the posts, e.g. as an intro to describe
      *  which posts are shown.
      */
      the_post(); 
    
      // Display content of page
      get_template_part( 'content', get_post_format() );
      wp_reset_postdata();
    
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
      $args = array(
    	// Change these category SLUGS to suit your use.
    	'category_name' => 'editions',
    	'paged' => $paged
      );
    
      $list_of_posts = new WP_Query( $args ); 
    
      twentyeleven_content_nav( 'nav-above' );
      while ( $list_of_posts->have_posts() ): $list_of_posts->the_post();
    
        // Display content of posts
        get_template_part( 'content', get_post_format() );
    
      endwhile;
      twentyeleven_content_nav( 'nav-below' );
      ?>
    
      </div><!-- /#content -->
    </div><!-- /#primary -->
    <?php get_footer();

    Please let me know if there is any more information I need to provide. I think this is a super easy fix but I’m new. Any help is deeply appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Page of Posts template problem’ is closed to new replies.