1

I have archive links in my theme that get the archives for a specfic category ('blog) like so:

 <?php wp_get_archives('cat=6'); ?>

When i click on the link for the archives is just loads the category page again for the blog.

The url does change to:

http://localhost:8888/2012/11/?cat=6

But nothing changes on the page.

4
  • That is an odd mix of pretty permalinks and default (straight PHP) permalinks. What setting do you have in wp-admin->Settings->Permalinks?
    – s_ha_dum
    Commented Nov 7, 2012 at 15:03
  • /%category%/%postname%/
    – Chris
    Commented Nov 7, 2012 at 15:04
  • Which field? "Custom Structure"? Does other URL rewriting work? What is the server (Apache, IIS, etc.) what is the OS of the server?
    – s_ha_dum
    Commented Nov 7, 2012 at 15:08
  • custom structure, server is apache and linux. On my category page I have it split with if statements to show the posts different depending if its in the blog section or work section. I wonder if this has something to do with it. But i cannot find where the archive code is.
    – Chris
    Commented Nov 7, 2012 at 15:11

1 Answer 1

1

OK. Here is your problem.

wp_get_archives( $args );
...
$args = array(
    'type'            => 'monthly',
    'limit'           => ,
    'format'          => 'html', 
    'before'          => ,
    'after'           => ,
    'show_post_count' => false,
    'echo'            => 1
);

You are use wp_get_archives incorrectly. That function accepts particular 'keys', and cat isn't one of them. You can use an array as above or the weird get-like string that is common in WordPress. You can't pass it values it isn't meant to handle though.

What you are seeing is the function fall back to its 'monthly' archive default, and apparently append your string to the end, which I wouldn't have expected.

Use get_category_link instead.

8
  • Ok, This has now started to work. But, how would I get archives from a certain cat?
    – Chris
    Commented Nov 7, 2012 at 15:27
  • Use get_category_link; see my answer.
    – s_ha_dum
    Commented Nov 7, 2012 at 15:29
  • Ok, but how can i filter these monthly?
    – Chris
    Commented Nov 7, 2012 at 15:31
  • I don't know of a function that will do that. Of course you can start filtering WP_Query
    – s_ha_dum
    Commented Nov 7, 2012 at 15:38
  • Sorry, what i mean is, when I click 'October'. How do i see all the posts from October? right now i just see one post, I need to see each post.
    – Chris
    Commented Nov 7, 2012 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.