We have permalink structure based on date (like 'www.mysite/2012/05/27/postname').
Some times there are some posts that we need to be shown the first, so we change they date.
The problem is, that by this way, after changing the date the URL is chenged also, so the old link causes 404 error.
Is there any solution for this problem?

  • Would it work to leave the date alone, and instead set the posts as sticky posts? That way the URL remains the same (I think) and you can make them show up first in your list.
    – Pat J
    May 27 '13 at 23:15
  • @PatJ, no. The archive page is ordered by date, so the setting as 'sticky' does not make any effect.
    – Shimon S
    May 28 '13 at 11:55

You'll need to add 301 redirects for the old URL to the new one. Your best bet is to do this via .htaccess, in your theme, or using a plugin like one of these:

Edit: Another option

OPtion 2 would be to disregard the date in the URI altogether. You could unset them from the request like so (add to your functions.php file):

function wpse_100936_request( $qv ) {
    if ( isset( $qv['name'], $qv['year'], $qv['monthnum'], $qv['day'] ) ) {
        unset( $qv['year'], $qv['monthnum'], $qv['day'] );
    return $qv;
add_action( 'request', 'wpse_100936_request' );

Then the date can change and not cause 404s. A post can now be accessed at any date, e.g. /2013/05/28/some-post/ and /1776/07/04/some-post/. SEO experts might warn you of "duplicate content", but the canonical meta tag will always point to the correct date, so that shouldn't be an issue. The only potential issue I can foresee is that, if someone linked to the post at the old date, they won't get redirected; whether that's important or not is up to you.

  • Yes, we use redirect plugin, but I am looking for some automatic solution, and not to enter new redirections manually for every date changing. (However its a right answer)
    – Shimon S
    May 28 '13 at 11:45
  • Truthfully, if your dates are changing frequently enough that manual redirect management is an issue, then you probably shouldn't be using date-based permalinks. That said, I added another option for you where you can simply ignore the date in the URI. May 28 '13 at 13:38
  • I found this solution useful brianhogg.com/… , we had over 300 blog posts on our site & doing it manually was a tedious job. Mar 8 '18 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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