• Resolved landwire

    (@landwire)


    Hi there,
    we have a custom page setup for our styling in our projects:

    add_filter('init', 'Flynt\BaseStyle\registerRewriteRule');
    
    const ROUTENAME = 'BaseStyle';
    
    function registerRewriteRule()
    {
        $routeName = ROUTENAME;
    
        add_rewrite_rule("{$routeName}/?$", "index.php?{$routeName}", "top");
        add_rewrite_tag("%{$routeName}%", "([^&]+)");
    }

    How can I exclude that page/post from being redirected to the home page?
    Basically in

    public function redirect_public_pages()

    it gets classed as a “blog_page” and therefore it is redirected.
    Is there a way to prevent redirection of that certain URL/page?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Joshua David Nelson

    (@joshuadnelson)

    Hey @landwire – thanks for reaching out on this.

    If that page returns true for the is_home() function, then it will be considered the “blog_page” by Disable Blog. You can filter the redirect url via the dwpb_redirect_blog_page filter, passing a false to disable the redirect for that template – just be sure you’re using some logic to confirm it’s your custom template and not the actual blog page.

    If that doesn’t work for some reason, there is a broader filter dwpb_redirect_front_end that toggles all front-end redirects. It will disable the redirect if it returns false. You could use a similar approach as above, checking that you’re on the specific page/template and returning false or, if you have a unique template file, you could drop this in it: add_filter( 'dwpb_redirect_front_end', '__return_false' );

    Let me know if you run into any issues or have any other questions.

    Thread Starter landwire

    (@landwire)

    @joshuadnelson
    Many thanks for the quick reply. The filters did not help, as the redirect was happening before. In the end we changed our custom URL to be a page instead of a post and everything works well now.

    Thanks for a great plugin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disable redirect for certain URL’ is closed to new replies.