• Resolved uzet1976

    (@uzet1976)


    Hey guys
    I have some categories for my posts,
    but one of the categories has to be shown in the blogs sidebar.
    I didn’t found a way to do that throught the normal widgets, and would like to write it code into the sidebar.

    How can I display the links to the posts in a single category?

    Thanks for the help!!!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Is your question that you wish to display all the categories in the sidebar?

    Thread Starter uzet1976

    (@uzet1976)

    No just the posts links in one category.

    Do u want to show all the postlinks in sidebar?

    Thread Starter uzet1976

    (@uzet1976)

    To show the posts links from single category in the sidebar.

    <?php
     $tmp = $wp_query;
     $wp_query = new WP_Query("cat=1&post_per_page=-1");
     if(have_posts()):
      echo "<ul>";
      while(have_posts()): the_post();
       echo "<li><a href='".the_permalink()."' rel='Bookmark of ".the_title()."'>".the_title()."</a></li>";
      endwhile;
      echo "</ul>";
     endif;
    
     $wp_query = $tmp;
    ?>

    Try this code once in your sidebar. Change the id 1 as your choice.

    Thanks
    Chinmoy

    Thread Starter uzet1976

    (@uzet1976)

    Thanks for your reply!

    I’m sorry,but it return gibrish.
    It prints the url,probably something is wrong with the tag.
    How to fix this?

    Thread Starter uzet1976

    (@uzet1976)

    By the way you hace a very informative blog!

    sorry! i have some mistake.
    It will posts_per_page not post_per_page. New code is

    <?php
     $tmp = $wp_query;
     $wp_query = new WP_Query("cat=1&posts_per_page=-1");
     if(have_posts()):
      echo "<ul>";
      while(have_posts()): the_post();
       echo "<li><a href='".the_permalink()."' rel='Bookmark of ".the_title()."'>".the_title()."</a></li>";
      endwhile;
      echo "</ul>";
     endif;
    
     $wp_query = $tmp;
    ?>

    If you get any error. send me that.

    Thread Starter uzet1976

    (@uzet1976)

    Thats the same thing again.
    by the way the codes looks the same?!

    what you want? I just display the post’s title on the sidebar of a specific category. You only change the cat id. Click on the title link, it will go to that specific post’s details page.

    Can you give your site link? I just check this.

    Thanks
    C

    Thread Starter uzet1976

    (@uzet1976)

    I really thank you for your help! I really do!
    You could check that link
    http://hashayara.co.il/
    The site is in hebrew,buy you could see what I mean under the youtube piece.
    Thanks!

    <?php
     $tmp = $wp_query;
     $wp_query = new WP_Query("cat=1&posts_per_page=-1");
     if(have_posts()):
      echo "<ul>";
      while(have_posts()): the_post();
    ?>
       <li><a href="<?php the_permalink() ?>" rel="Bookmark of <?php the_title() ?>"><?php the_title() ?><br/><br/><?php the_excerpt() ?></a></li>
    <?php
      endwhile;
      echo "</ul>";
     endif;
    
     $wp_query = $tmp;
    ?>

    Try this once. I changed something.

    Thread Starter uzet1976

    (@uzet1976)

    Great!!!
    That works!!!
    Thank!

    I show it on your site.

    if you not want to content, so delete this code <br/><br/><?php the_excerpt() ?>;

    You’re also welcome. 🙂

    Thanks
    Chinmoy

    If solve all your issue, plz mark it as resolved.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘displaying only one category posts in a sidebar’ is closed to new replies.