views:

179

answers:

1

Hello,

I created an Archive list (also this is my archive.php codes) on my blog and i want to show posts by years.

But when i use query_posts() function for excluding some categories and limit posts then it's showing all posts not by year.

For example this page is showing all posts not only posts in 2009 years.

So if i summarize this issue; i want to show archive list by year (when i enter /2009/ permalink)+exclude some categories and limit posts.

Thank you.

+3  A: 

maybe when you use global variable, $query_string, it will help.

so you must use it like this

global $query_string; query_posts($query_string . '&cat=-13,-4,-14,-171&posts_per_page=5&paged='. $paged);

as codex mention, here : query post,

Place a call to query_posts() in one of your Template files before The Loop begins. The wp_query object will generate a new SQL query using your parameters. When you do this, WordPress ignores the other parameters it receives via the URL (such as page number or category). If you want to preserve that information, you can use the $query_string global variable in the call to query_posts().
justjoe
Thanks. It's working but there are new problem with pagination. If i click previous post link (Önceki Sayfa -> (http://snipurl.com/uwvyo)) on this page (http://snipurl.com/uwvxv) then it's returning error 404 page. This is my new archive.php codes (http://www.pastie.org/private/0ddd1n4nxhoouguq3ahdfg). How i can fix this issue?
fatihturan
what happen if you use http://codex.wordpress.org/Function_Reference/wp_reset_query | wp_reset_query(), after the loop and before a pagination...
justjoe
Thanks you sir. It's worked. I want to ask new question about this topic; query_posts() function is not excluding some categories (i.e: category id=13). Latest archive.php codes is here: http://bit.ly/bjYljq Why so? I can't understand.
fatihturan
how about you use '
justjoe
Problem solved. :) Thank you so much.
fatihturan
your're welcome
justjoe