Create WordPress Page that redirects to another URL

前端 未结 9 1826
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 02:40

I wanted to create a new WordPress page that is actually a link to another site. The goal is to have the page show up in a list of my pages, but actually send the web user to t

相关标签:
9条回答
  • 2021-02-01 03:21

    Use the "raw" plugin https://wordpress.org/plugins/raw-html/ Then it's as simple as:

    [raw]
    <script>
    window.location = "http://www.site.com/new_location";
    </script>
    [/raw]
    
    0 讨论(0)
  • 2021-02-01 03:21

    There are 3 ways of doing this:

    1. By changing your 404.php code.
    2. By using wordpress plugins.
    3. By editing your .htaccess file.

    Complete tutorial given at http://bornvirtual.com/wordpress/redirect-404-error-in-wordpress/906/

    0 讨论(0)
  • 2021-02-01 03:23

    You can accomplish this two ways, both of which need to be done through editing your template files.

    The first one is just to add an html link to your navigation where ever you want it to show up.

    The second (and my guess, the one you're looking for) is to create a new page template, which isn't too difficult if you have the ability to create a new .php file in your theme/template directory. Something like the below code should do:

    <?php /*  
    Template Name: Page Redirect
    */ 
    
    header('Location: http://www.nameofnewsite.com');
    exit();
    
    ?>
    

    Where the template name is whatever you want to set it too and the url in the header function is the new url you want to direct a user to. After you modify the above code to meet your needs, save it in a php file in your active theme folder to the template name. So, if you leave the name of your template "Page Redirect" name the php file page-redirect.php.

    After that's been saved, log into your WordPress backend, and create a new page. You can add a title and content to the body if you'd like, but the important thing to note is that on the right hand side, there should be a drop down option for you to choose which page template to use, with default showing first. In that drop down list, there should be the name of the new template file to use. Select the new template, publish the page, and you should be golden.

    Also, you can do this dynamically as well by using the Custom Fields section below the body editor. If you're interested, let me know and I can paste the code for that guy in a new response.

    0 讨论(0)
提交回复
热议问题