• Hi,

    I have a template that displays the homepage.
    I would like to be able to display the POSTS underneath that page?!

    here is my home template:

    <?php
    /*
    Template Name: Homepage
    */
    ?>
    
    <?php get_header(); ?>
    
    <section id="omc-main">	
    
    				<?php
          $dispalyed = false;
          if (function_exists('shareit_output')) {
            $h_sticky = shareit_output();
            $home_page = get_option ('shareit_home', 0);
            if (!$displayed and $h_sticky && $home_page == 1) {
              echo $h_sticky;
              $displayed = true;
            }
          }
          ?>
    	<?php get_template_part( 'loop', 'flexslider-homepage' ); ?>
    
    	<?php 	if ( have_posts() ) : while ( have_posts() ) : the_post(); 	?>
    
    		<?php the_content(); ?>		
    
    	<?php endwhile; endif; ?>	
    
    	<br class="clear" />
    
    </section><!-- /main -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • add a secondary loop, possibly before </section><!-- /main -->;

    example:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
      $args = array(
    	'posts_per_page' => 10,
    	'paged' => $paged
      );
    
      $list_of_posts = new WP_Query( $args ); 
    
      while ( $list_of_posts->have_posts() ): $list_of_posts->the_post();
    
        // Display content of posts
        //use the respective code from index.php of your theme
    
      endwhile; wp_reset_postdata();
    ?>

    you might need to add more specific query args, and/or add html tags to structure the output;

    http://codex.wordpress.org/The_Loop
    http://codex.wordpress.org/Class_Reference/WP_Query
    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
    http://codex.wordpress.org/Pages#A_Page_of_Posts

    Thread Starter jbiddulph

    (@jbiddulph)

    thanks, but your example broke my page?!

    It’s just blank

    look here

    my mistake – quite a few typing errors ;-(

    – this should be: 'posts_per_page' => 10,
    – and this should be: wp_reset_postdata();

    corrected in total in my original reply.

    Thread Starter jbiddulph

    (@jbiddulph)

    thanks but my page is still blank,

    here is my code

    <?php
    /*
    Template Name: Homepage
    */
    ?>
    
    <?php get_header(); ?>
    
    <section id="omc-main">	
    
    				<?php
          $dispalyed = false;
          if (function_exists('shareit_output')) {
            $h_sticky = shareit_output();
            $home_page = get_option ('shareit_home', 0);
            if (!$displayed and $h_sticky && $home_page == 1) {
              echo $h_sticky;
              $displayed = true;
            }
          }
          ?>
    	<?php get_template_part( 'loop', 'flexslider-homepage' ); ?>
    
    	<?php 	if ( have_posts() ) : while ( have_posts() ) : the_post(); 	?>
    
    		<?php the_content(); ?>		
    
    	<?php endwhile; endif; ?>	
    
    	<br class="clear" />
    	<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
      $args = array(
    	'posts_per_page' => 10;
    	'paged' => $paged
      );
    
      $list_of_posts = new WP_Query( $args ); 
    
      while ( $list_of_posts->have_posts() ): $list_of_posts->the_post();
    
        // Display content of posts
        //use the respective code from index.php of your theme
    
      endwhile; wp_reset_postdata();
    ?>
    </section><!-- /main -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Thread Starter jbiddulph

    (@jbiddulph)

    please help

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How can I display the POSTS underneath a page in a page template’ is closed to new replies.