Is your question that you wish to display all the categories in the sidebar?
No just the posts links in one category.
Do u want to show all the postlinks in sidebar?
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
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?
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.
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
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.
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.