Forums

How to add more headlines in sidebar (6 posts)

  1. enviado
    Member
    Posted 2 years ago #

    Hi!

    This is one of my websites: http://www.enviadoespecial.es In the main page there are 9 news and they are ordered by date (newest the first, etc).

    Each new new removes the oldest of the main page, and i'd like the 10th, 11st, 12nd, 13rd, 14th, 15th and 16th appeared in the sidebar just like headline and if is possible, with a very small thumbnail.

    You can see better what i mean here:

    http://www.enviadoespecial.es/wp-content/themes/enviadoespecial/images/index.jpg

    I hope anyone can help me, thanks!!!

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Something like:

    <ul>
     <?php
     $side_posts = get_posts('numberposts=7&offset=10');
     foreach($side_posts as $post) :
     setup_postdata($post); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
     </ul>
     <?php wp_reset_query();?>

    should work.

    http://codex.wordpress.org/Template_Tags/get_posts

  3. enviado
    Member
    Posted 2 years ago #

    Thanks esmi! It works as i want but i dont know what happens with the thumbnail. It shows different in the sidebar than in the content. This is the code in index:

    </p>
    		<a href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?></a>
    		<?php the_excerpt(); ?>

    And i ve put in the sidebar like:

    <?php
     $side_posts = get_posts('numberposts=5&offset=10');
     foreach($side_posts as $post) :
     setup_postdata($post); ?>
    <li><p><a href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?></a>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p></li>
     <?php endforeach; ?>
     </ul>
     <?php wp_reset_query();?>

    But the image post is bigger than in the index...

    By the way, this are the lines about thumbnail in functions.php:

    # Displays post image attachment (sizes: thumbnail, medium, full)
    function dp_attachment_image($postid=0, $size='thumbnail', $attributes='') {
    	if ($postid<1) $postid = get_the_ID();
    	if ($images = get_children(array(
    		'post_parent' => $postid,
    		'post_type' => 'attachment',
    		'numberposts' => 1,
    		'post_mime_type' => 'image',)))
    		foreach($images as $image) {
    			$attachment=wp_get_attachment_image_src($image->ID, $size);
    			?><img src="<?php echo $attachment[0]; ?>" <?php echo $attributes; ?> /><?php
    		}
    }

    Any help with this?

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    The following CSS is almost certainly reducing the final displayed image size in the content area:

    #content .post img {
    border:3px solid #EFEFEF;
    float:left;
    margin:2px 8px 4px 0;
    width:94px;
    }
  5. enviado
    Member
    Posted 2 years ago #

    Thanks again, esmi, but it doesn't work... i ve changed the css like this:

    #sidebar .post img {
    border:3px solid #EFEFEF;
    float:left;
    margin:2px 8px 4px 0;
    width:94px;
    }

    But nothing happens... the size of the thumbnail is not the same than in #content...

  6. enviado
    Member
    Posted 2 years ago #

    well, i'll try to ask in the css forum

Topic Closed

This topic has been closed to new replies.

About this Topic