Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author reviewsquirrel

    (@reviewsquirrel)

    Sorry to hear that Arno, but what did you set the redirect to URL as? Redirect to URL should be 200-OK and you need to specify its URL including protocol, e.g. https://www.google.com not https://www.google.com

    dfeagin

    (@dfeagin)

    I experienced the same thing. When the page expired it generated a 404 vs. redirecting to the new page that we had created on the site. The URL was set correctly.

    I’m having the same issues. I tried the redirect with both http and https and it returns as a 404. The URL is correct.

    I figured out the problem.

    Short answer:
    Edit the content-expiration-and-redirect.php file. Replace line 59:
    $id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name));
    with the following:
    $id = $query->queried_object->ID;

    Long answer:
    The reason it isn’t working is because when the page is expired you can’t retrieve the ID using get_the_ID(). Instead, the author does a DB Query looking for a post name that matches the URL path. With the current setup, it will always work for posts and pages that use this format: https://www.sample.com/postname. However, if you have something like https://www.sample.com/category/postname, the query fails to find the post data and will always return a 404 error.
    Luckily, the ID is already in the Query Object being used to retrieve the post name. It’s just hidden a little deeper. Using the line above you’ll always retrieve the correct ID, whether the page has expired or not.

    I hope the author manages to update this soon. This is actually a really useful and easy to use plugin.

    FYI: With this change line 58 ($name = isset...) becomes unnecessary so that can be deleted too.

    Plugin Author reviewsquirrel

    (@reviewsquirrel)

    Thanks @luisten, excellent eagle eyes ?? I made the tweak as per your suggestion

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Expired pages will only return HTTP 404’ is closed to new replies.