1

I'm using Wordpress 4.1.1. I have come across a problem with my website archives. If I set the permalinks to default I can click on a category and then click on the date on the sidebar within this category and it displays results for that month. This is the permalink:

?cat=16&m=201503

However if I change the permalinks to Post Name I get this structure:

category/category-1/?m=201503

but I don't arrive at the page. It just times out. I don't even get re-direct to a 404 page. I get page with this message:

The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Have I set up my permalink structure incorrectly? Or is this some other issue?

0

1 Answer 1

0

A canonical redirect:

The GET parameter m can trigger a canonical redirect when permalinks are used.

The canonical redirects are activated with the following hook:

add_action('template_redirect', 'redirect_canonical');

where redirect_canonical() is a rather complicated function.

Here's the skeleton of the part that's active within this "monster" callback:

// ... cut ...

if ( is_404() ) {

    // ... cut ...

} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {

   if( ... ) {

      // ... cut ...

    } elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {

        // --> We are here <---  ;-)

    } elseif( ... ) {

    // ... cut ...

}

// ... cut ...

where $_GET['m'] is non-empty.

In your case when $m has the YYYYMM format, is_month() is also true and we get the following redirect:

$redirect_url = get_month_link( substr($m, 0, 4), substr($m, 4, 2) );

so we should be redirected from:

http://example.tld/category/category-1/?m=201503

to:

 http://example.tld/2015/03

A possible workaround would by to use instead:

http://example.tld/2015/03/?cat=16

to avoid the canonical redirect process.

You should also try this on a vanilla install: default theme and no plugins to avoid your infinite redirect loop problem.

4
  • Thank you for explaining that to me. What do I do with the example.tld/2015/03/?cat=16 ?
    – MrFox
    Commented Mar 18, 2015 at 16:44
  • This was just an example you one could filter the posts by both date and category, without the canonical redirection. I don't think your click-combination will work by default for permalinks. I tried it on the default theme, but didn't succeed with the permalinks off. One would need to handle this with somekind of GET parameters collector for the links. @Gennie
    – birgire
    Commented Mar 18, 2015 at 17:21
  • ps: I meant to write in the above comment: "you one could" as "how one could" ;-)
    – birgire
    Commented Mar 18, 2015 at 17:30
  • Well, I gave up and I've created a new sidebar for category archive pages which does not display the monthly archive widget.
    – MrFox
    Commented Mar 19, 2015 at 14:54

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.