• I’m giving my blog another use, and I need to remove “Recent posts” from the sidebar. I’m using a custom home template, so it’s not a widget I put there.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Assuming this custom home template is including the standard sidebar.php file, I would open sidebar.php and look for something like this:

    <?php get_archives('postbypost', '10', 'custom', '<li>', '</li>'); ?>

    You are basically looking for the function that is displaying the recent posts and removing that. There is probably a title that goes along with it, so you will need to remove that as well. Look for something lie:

    <h2><?php _e('Recent Posts'); ?></h2>

    The template could also be calling a plugin or custom function by another name.

    Thread Starter dekmar

    (@dekmar)

    I have this on my sidebar.php:

    <h2 class="sidebartitle widget_recent_entries">
            <?php _e('Mensajes recientes'); ?>
           </h2>
    
    <ul>
    		<?php $recent = new WP_Query("showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
    
    <li><a>">
              <?php the_title(); ?>
              </a>  </li>
            <?php endwhile; ?>
          	</ul>

    I recognize this (<?php _e('Mensajes recientes'); ?>) as the title, because I changed it from English to Spanish, but I’m not sure about the rest I have to remove.

    That looks like the right code to remove. You will probably want to get rid of all that, but if you want to test it out just remove

    <?php the_title(); ?>

    and

    <?php _e('Mensajes recientes'); ?>

    to start. This will still run the query but wont display anything. If this removes the content you want, the go back and get rid of the rest.

    Thread Starter dekmar

    (@dekmar)

    I removed the content as per your instructions, and then I kept removing the rest.

    I only have this at the top of my sidebar.php now:

    <div id="sidebar">
    	       <div class="scenter">
    
        <div class="sbottom"></div>
    
          <div class="stop"></div>
         <div class="scenter">
    
    <ul>

    There is still one empty bar showing at the top of the sidebar, but it looks kinda like a decoration that’s part of the theme, so I think I’ll leave it there. Maybe no one will notice it’s a glitch…

    Thank you very much for your help.

    The empty bar is a result of CSS classes.

    edit the styles.css if you want remove the bottom border.

    -I should read before I answer-

    I agree with spstieng. Unfortuantely, the css class names and their definitions in style.css are specific to your theme, so, I couldn’t really tell you what “scenter” or “sbottom” do. As spstieng suggested you can look up those classes in your style.css class and remove them or remove lines that look like border:1px solid #000; frome their definitions.

    You can also try removing the <div> from your sidebar.php. For example you could remove <div class="sbottom"></div> or try <div class="stop"></div>

    The only problem here is that if these classes are using floats or clearing floats it could mess up your layout.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to remove ‘Recent Posts’ from sidebar’ is closed to new replies.