最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

homepage - Setting a permalink for the home page?

programmeradmin0浏览0评论

I have a static default wordpress home page. As you know if you have a homepage on wordpress you can not set a permalink through the admin options, you can only set permalinks for non homepages. Does anyone know of a way that I can set a permalink for my homepage? So that when I visit my site at example, it automatically turns to example/examplelink when the site loads?

Thank you!!

I have a static default wordpress home page. As you know if you have a homepage on wordpress you can not set a permalink through the admin options, you can only set permalinks for non homepages. Does anyone know of a way that I can set a permalink for my homepage? So that when I visit my site at example, it automatically turns to example/examplelink when the site loads?

Thank you!!

Share Improve this question asked Apr 3, 2014 at 21:40 user49894user49894 311 gold badge1 silver badge2 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 3

I would set another page as the home page, add a custom template for the home page and put this in it:

<?php wp_redirect( get_permalink( $id ), 301 ); exit; ?>

If you dont want to set the id manually you can do:

1) create a template page-template-homepage-redirect.php in your theme

<?php
/*
Template Name: homepage redirect
*/
wp_redirect(  get_permalink( wp_get_post_parent_id( $post_ID ) ), 301 );
exit;
?>

2) create an empty page and use this newly created template

3) Go to settings - Reading and set this new page to static homepage

4) change the slug/permalink of the original homepage to what you'd like to see

5) go back to pages and make sure you set the original homepage you want to redirect to is the parent of the "homepage redirect" page

发布评论

评论列表(0)

  1. 暂无评论