Results 1 to 9 of 9

Thread: help with sidebar an new posts from categories

  1. #1
    Lightfire is offline Hello World
    Join Date
    Jan 2010
    Posts
    4

    Default help with sidebar an new posts from categories

    Hey guys,
    I'm kind of new here so please apologize if i do anything wrong (since i'm from germany there could be slight mistakes with grammar or so ;) ).

    I've got a 2-column wordpress blog with the posts on the left sight and a sightbar on the right. I've tried desperately to modify the sidebar so i could get 2 links in there but i failed. The links should refer to the two newest posts in one specific category.

    Does anyone of you know how this would be possible? (btw. i'm still using wordpress 2.3.1 and i've got no possibility to upgrade any time soon)

    Thanks a lot

  2. #2
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,797

  3. #3
    Edwin is offline Hello World
    Join Date
    Nov 2009
    Posts
    47

    Default

    Quote Originally Posted by Lightfire View Post
    Hey guys,
    I'm kind of new here so please apologize if i do anything wrong (since i'm from germany there could be slight mistakes with grammar or so ;) ).

    I've got a 2-column wordpress blog with the posts on the left sight and a sightbar on the right. I've tried desperately to modify the sidebar so i could get 2 links in there but i failed. The links should refer to the two newest posts in one specific category.

    Does anyone of you know how this would be possible? (btw. i'm still using wordpress 2.3.1 and i've got no possibility to upgrade any time soon)

    Thanks a lot
    You'll have to create a div container, for example:

    Code:
    <div id="latestposts"></div>
    And then insert it into your sidebar.php file or whatever file your theme is using for the sidebar where you want the links to appear.

    In the div you past this code:

    PHP Code:
    <ul>
    <?php $recent = new WP_Query("cat=1&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark">
    <?php the_title(); ?>
    </a></li>
    <?php endwhile; ?>
    </ul>
    PHP Code:
    "cat=1&showposts=10" 
    To change the category value just interchange "1" with the category number you want the two post from to appear.

    If you want more posts simply change the "2" value to any number you want.

    You'll have to style the links on your own.


    If you need more help post a link to your blog or post your sidebar code and your css file's code and I would be happy to help out.

  4. #4
    Lightfire is offline Hello World
    Join Date
    Jan 2010
    Posts
    4

    Default

    Thanks a lot

  5. #5
    Jeffro's Avatar
    Jeffro is offline WPTavern Forum Admin
    Join Date
    Jan 2009
    Location
    Ohio
    Posts
    2,358

    Default

    Ok, you mentioned it so I'm going to ask, how in the world did you get yourself in a position where you're still using WordPress 2.3.1 and have no upgrade chance in the foreseeable future?

  6. #6
    Lightfire is offline Hello World
    Join Date
    Jan 2010
    Posts
    4

    Default

    Glad you ask
    It is for a page at which I am not the server admin and therefore i got no ftp rights. Our server admin is very busy with his work but want's to update soon (at least he sais so since novembre -.-). He works as a SEO and doesn't trust anyone lightly. So it's kind of a dead end^^

    I got a new question about this problem. I tried to get the links to work on pictures... Perhaps you could look at the code again and tell me what i do wrong

    Code:
    <?php
        $i=0;
        $arr = array("http://www.w-i.de/pic1.png","http://www.w-i.de/pic2.png");
    ?>
    
    <div class="col2_box">
     <ul>
      <?php $recent = new WP_Query("cat=2010&showposts=2"); while($recent->have_posts()) : $recent->the_post();?>
       <li><a href="<?php the_permalink() ?>" rel="bookmark">
        <img src="<?php $arr[$i]; ?>" />
       </a></li>
       <?php $i=1; ?>
      <?php endwhile; ?>
     </ul>
    </div>

  7. #7
    andrea_r's Avatar
    andrea_r is offline WordPress Rockstar
    Join Date
    Jan 2009
    Location
    Eastern Canada
    Posts
    1,325

    Default

    . He works as a SEO and doesn't trust anyone lightly.
    SEO won't help much if the site gets hacked because he failed to upgrade in a timely manner.

  8. #8
    Lightfire is offline Hello World
    Join Date
    Jan 2010
    Posts
    4

    Default

    I've tried another way to link the posts on images, but still it won't work. Think the problem is with the arrays. Can someone tell me what's wrong with that?

    Code:
    <div class="col2_box">
      <?php $mylinks=array(); $recent = new WP_Query("cat=2010&showposts=2"); while($recent->have_posts()) : $recent->the_post();?>
       <?php $mylinks[]= get_permalink() ?>
      <?php endwhile; ?>
     <a href="<?php $mylinks[0] ?>"><img src="http://www.w-i.de/pic2.png" /></a><br />
     <a href="<?php $mylinks[1] ?>"><img src="http://www.w-i.de/pic1.png" /></a>
    </div>
    The pictures are displayed, but somehow the links don't work

  9. #9
    Edwin is offline Hello World
    Join Date
    Nov 2009
    Posts
    47

    Default

    Quote Originally Posted by Lightfire View Post
    I got a new question about this problem. I tried to get the links to work on pictures... Perhaps you could look at the code again and tell me what i do wrong

    Code:
    <?php
        $i=0;
        $arr = array("http://www.w-i.de/pic1.png","http://www.w-i.de/pic2.png");
    ?>
    
    <div class="col2_box">
     <ul>
      <?php $recent = new WP_Query("cat=2010&showposts=2"); while($recent->have_posts()) : $recent->the_post();?>
       <li><a href="<?php the_permalink() ?>" rel="bookmark">
        <img src="<?php $arr[$i]; ?>" />
       </a></li>
       <?php $i=1; ?>
      <?php endwhile; ?>
     </ul>
    </div>
    If I could I would let you know, unfortunately I have no idea...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •