• Resolved mstudioIL

    (@mstudioil)


    I have top page and I want to redirect it to sub page, how can I do it?
    Can it be 301 redirection?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @mstudioil,

    That can be tricky depending on how the page URL is structured.

    You can start with this code and adjust to your page URLs

    add_action('init', function() {
        if ( is_page('parent-page') ) {
            wp_redirect( home_url('/parent-page/subpage/'), 301 );
            exit;
        }
    });

    This can be used set to auto-insert Location “Frontend Only” in WPCode as a PHP snippet.

    • This reply was modified 1 month ago by Mircea Sandu. Reason: added 301
    Thread Starter mstudioIL

    (@mstudioil)

    Thanks. can you please add this to your example in the plugin? I didn’t found it
    Redirection are important.

    Is it better to use “home_url” over the full URL?

    • This reply was modified 1 month ago by mstudioIL.
    Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @mstudioil,

    Thank you for the suggestion, we’ll consider a way to do that, this snippet is quite specific and we try to keep the snippets in the library that get loaded in the plugin as generic as possible.

    Yes, it’s better to use home_url as that will dynamically use your site’s URL and it should be more reliable.

    Thread Starter mstudioIL

    (@mstudioil)

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.