Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I tested the code from the article, and yeah, in fact it has some problems:

    • It does not define the URL ‘/dfrapi-redirect’ as recognizable by WordPress
    • Which trigger a 404 error
    • Which trigger WP 404 Auto Redirect to Similar Post plugin

    Even if you disable my plugin, the code above will still trigger a 404 error page, but with custom content (which I would not recommend, as it could increase 404 errors crawls by Google).

    Anyway, I just pushed an update which let you customize the behavior of the plugin for specific cases like yours. Please update it.

    Based on the code you sent, here is an addon you should copy/paste (after the code you took from the article) in order to make it compatible with WP 404 Auto Redirect to Similar Post:

    
    add_filter('wp404arsp/init', 'wp404arsp_dfrapi_init');
    function wp404arsp_dfrapi_init($init){
        $id = (isset($_GET['dfrapi_id'])) ? urldecode($_GET['dfrapi_id']) : false;
        $url = (isset($_GET['dfrapi_url']) && ! empty($_GET['dfrapi_url'])) ? urldecode($_GET['dfrapi_url']) : false;
        
        if(!$url || !$id)
            return $init;
        
        return false;
    }
    
    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    BTW, if you want to avoid to trigger a 404 headers with the code from the article, you should also add the following code, so WordPress will fully understand what your ‘dfrapi-redirect’ URL is:

    
    add_action('init', 'dfrapi_rewrite_rule');
    function dfrapi_rewrite_rule(){
        add_rewrite_rule('^dfrapi-redirect/?', 'index.php?dfrapi-redirect', 'top');
    }
    
    add_filter('query_vars', 'dfrapi_query_vars');
    function dfrapi_query_vars($query_vars){
        $query_vars[] = 'dfrapi-redirect';
        return $query_vars;
    }
    

    Note: This code also fix the problem alone (without my first answer’s code). As this will prevent WordPress to trigger a 404 error, so it will also stop to trigger WP 404 Auto Redirect to Similar Post for URLS like ‘my-website.com/dfrapi-redirect’ ??

    Thread Starter athleticcity

    (@athleticcity)

    Hi,

    PERFECT. I added all codes now. It works.

    Thanks a lot.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    I’m glad to hear it. Remember to write a rating if you found this plugin helpful, I always appreciate it ??

    Have a good day!

    Regards.

    Thread Starter athleticcity

    (@athleticcity)

    Did it. ??

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Thanks buddy ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Problem with exit page’ is closed to new replies.