WordPress.org

Ready to get started?Download WordPress

Forums

Creating a Page With Posts (13 posts)

  1. rusticblonde
    Member
    Posted 1 year ago #

    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

  2. rusticblonde
    Member
    Posted 1 year ago #

    <?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

  3. rusticblonde
    Member
    Posted 1 year ago #

    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

  4. rusticblonde
    Member
    Posted 1 year ago #

    <?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

  5. esmi
    Forum Moderator
    Posted 1 year ago #

  6. rusticblonde
    Member
    Posted 1 year ago #

    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

  7. rusticblonde
    Member
    Posted 1 year ago #

    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?

  8. rusticblonde
    Member
    Posted 1 year ago #

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

  9. rusticblonde
    Member
    Posted 1 year ago #

    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

  10. rusticblonde
    Member
    Posted 1 year ago #

    <?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

  11. rusticblonde
    Member
    Posted 1 year ago #

    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

  12. esmi
    Forum Moderator
    Posted 1 year ago #

    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)

  13. rusticblonde
    Member
    Posted 1 year ago #

    oh right! that makes sense now Esmi.

    I think i need to get a tutorial :)

    thankyou for the help

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.