WordPress.org

Ready to get started?Download WordPress

Forums

Carry posts on in the sidebar (2 posts)

  1. joshuahornby
    Member
    Posted 1 year ago #

    In the sidebar instead of navigation or lists I want to display more blogposts on the homepage. How do i go about doing this?

    <?php get_header(); ?>
      <div class="page-wrap group">
    
        <div class="grid">
    
          <?php query_posts('showposts=4'); ?>
    
            <?php if (have_posts()): ?>
    
          <section class="blog-posts col-2-3 grid-pad">
    
            <?php while (have_posts()) : the_post(); ?>
    
              <article class="module" id="post-<?php the_ID(); ?>">
    
                <h2> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                <p class="time"><?php the_date(); ?> by <?php the_author(); ?></p>
    
                <?php the_excerpt(); ?>
    
              </article>
    
              <?php endwhile; ?>
    
          </section>
    
    <?php else: ?>
    
      <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>

    The is the current code for getting blogposts. The side bar will look like so

    <aside class="col-1-3 grid-pad">
    	<article class="module">
    <?php ?>
    	</article>
    </aside>

    How do i carry my loop on into the sidebar?

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    What is displayed in 'the content' and in the sidebar are 'different monkeys'...think of it this way...A Page Template in your theme controls the HTML and Styles (CSS) output - and also then grabs the sidebar (widgets)...

    If I wanted multiple columns in a site, I work with a custom Page Template, adjust accordingly, create my custom CSS rules, and then either grab the sidebar also, or not....

    All this work will be best done in a Child Theme.

    Search here for help on items italicized.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags