Create WordPress Page that redirects to another URL

前端 未结 9 1829
被撕碎了的回忆
被撕碎了的回忆 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:10

    I'm not familiar with Wordpress templates, but I'm assuming that headers are sent to the browser by WP before your template is even loaded. Because of that, the common redirection method of:

    header("Location: new_url");
    

    won't work. Unless there's a way to force sending headers through a template before WP does anything, you'll need to use some Javascript like so:

    
    

    Put that in the section and it'll be run when the page loads. This method won't be instant, and it also won't work for people with Javascript disabled.

提交回复
热议问题