Support » Themes and Templates » Creating a Page With Posts

  • Hi all! Ive been looking through the topics and nothing really has answered my question.

    Is there a basic format for just calling posts within a template? As im totally struggling to find the code

    Basically i want my front page, ie my template just to call all posts abit like a blog.

    Thanks
    Kirsty

Viewing 12 replies - 1 through 12 (of 12 total)
  • <?php get_header(); ?>
    <div id="content">
    
    	<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar() ) : else : ?>
    	<?php endif; ?>
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		<div class="post">
    			<div class="post-title">
    
    				<span class="post-cat"><?php the_category(', ') ?></span> 
    
    			</div>
    			<div class="entry">
    				<?php the_content('Read the rest of this entry &raquo;'); ?>
    			</div>
    		</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<span class="previous-entries"><?php next_posts_link('Older Entries') ?></span>
    			<span class="next-entries"><?php previous_posts_link('Newer Entries') ?></span>
    		</div>
    
    	<?php else : ?>
    
    		<h2>Not Found</h2>
    		<p>Sorry, but you are looking for something that isn't here.</p>
    
    	<?php endif; ?>
    
    	</div>
    	<!--/content -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    This is the code for my page.php… but its not displaying any posts now so im really confused

    Because as soon as i click the home link the posts disappear

    http://rusticblonde.hostizzo.com/TestSites/

    Your help is appreciated guys 🙂

    thanks in advance and sorry for long post

    <?php get_header(); ?>
    <div id="content">
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_content (); ?>
    <?php endwhile; ?>
    <?php endif; ?>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    New page template code…. and its still not calling my posts… and this is from a tut

    esmi

    (@esmi)

    Forum Moderator

    Hi Esmi,

    Thanks for this. However im lost about it. When it says code the HTML. Is it that i copy the head at the beginning of the theme?

    thanks for the fast response.

    Kirsty

    or do i have to change the

    <?php twentyeleven_content_nav( 'nav-above' );?>
    to state ie if my theme was called bob

    `<?php bob_content_nav ( ‘nav-above’) ;?>

    is the above referencing to a div in the css?

    apologies about the less back ticks.. .i thought id copied and pasted them

    Hi Esme,

    Im sorry im lost with what and where im supposed to replace from this to fit my theme. Is it all the parts that mention the Twenty Twelve theme?

    Sorry for all the qs

    <?php get_header(); ?>
    
    <div id="main">
      <div id="content">
        <h1>Main Area</h1>
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <h1><?php the_title(); ?></h1>
        <h4>Posted on <?php the_time('F jS, Y') ?></h4>
        <p><?php the_content(__('(more...)')); ?></p>
        <hr>
        <?php endwhile; else: ?>
        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
        <?php endif; ?>
      </div>
    
      <?php get_sidebar(); ?>
    
      </div>
    
    <div id="delimiter"></div>
    
    <?php get_footer(); ?>

    ok now im confused… as i cannot see why this is not working :S

    Hi all,

    Can i ask why even the basic loop is not working on my page, as ive tried posting that and im having little luck on anything!

    thx

    esmi

    (@esmi)

    Forum Moderator

    The basic Loop only generates content that you have actually posted in that particular Page. It will not pull in content from other posts. For that you need to customise the main query. See:

    http://codex.wordpress.org/Function_Reference/query_posts
    http://codex.wordpress.org/Function_Reference/WP_Query (for a list of possible parameters)

    oh right! that makes sense now Esmi.

    I think i need to get a tutorial 🙂

    thankyou for the help

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Creating a Page With Posts’ is closed to new replies.