• Resolved Magdalena Halford

    (@magdalena-halford)


    Hi – I am trying to edit this theme to show “recent posts” instead of “recent comments” in the bottombar on the home page. I have no idea how to change the code to do this. here is the code from the bootombar file:
    Can some please tell me how to change this so it pulls posts instead of comments? Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Magdalena Halford

    (@magdalena-halford)

    For some reason the bit of code I posted caused some formatting in my question above – not sure how to avoid that, new here . . . just saw the node about putting code into backticks

    Thread Starter Magdalena Halford

    (@magdalena-halford)

    <h2 class="bottombartitle"><?php _e('Recent Comments'); ?></h2>
    	    <?php
    		global $comment;
    		if ( $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved='1' ORDER BY comment_date_gmt
    		DESC LIMIT 5") ) :
    		?>	
    
    		<ul class="list-archives">
    			<?php
    			foreach ($comments as $comment) {
    				echo '<li><a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '"><font color="#222222">' . sprintf('%s...', substr(strip_tags($comment->comment_content), 0, 80)).'</font><br />'.get_comment_author($comment->comment_post_ID).'</a>';
    			echo '</li>';
    			}
    			?>
    		</ul>
    <h2 class="bottombartitle"><?php _e('Recent Posts'); ?></h2>
    <?php
    query_posts('showposts=5');
    if(have_posts()) :
    ?>
    <ul class="list-archives">
    <?php while(have_posts()) : the_post(); ?>
      <li><?php the_permalink(); ?></li>
    <?php endwhile; ?>
    </ul>
    <?php
    endif;
    wp_reset_query();
    ?>
    Thread Starter Magdalena Halford

    (@magdalena-halford)

    That almost worked – but the recent post title looks like a link (but is not a link) – you can see it here

    oh, use
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    instead of
    <li><?php the_permalink(); ?></li>

    Thread Starter Magdalena Halford

    (@magdalena-halford)

    excellent, that worked – thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Help with corporate theme bottombar – how to add recent posts’ is closed to new replies.