admin管理员组

文章数量:1398761

I am trying to figure out what is the best practice to allow a customizable static page to show on the top of the dynamic front home page. What I am asking is not using a custom page a such as front-page.php because I would like to setup "Front page displays - Your latest posts" in the Wordpress > Settings > Reading section and the dynamic page to be the front page. What is the way to add some javascript to functions.php or index.php or any other file to load a custom page before the dynamic page so the both pages will show on the home page. I have done it a long time ago and do not remember any more. This is the website I did it for . The reason I am trying to do it that way is because I am trying to use the templates for the blog style from the theme I am using and do not want to just add the blog section and try to customize. Thank you.

I am trying to figure out what is the best practice to allow a customizable static page to show on the top of the dynamic front home page. What I am asking is not using a custom page a such as front-page.php because I would like to setup "Front page displays - Your latest posts" in the Wordpress > Settings > Reading section and the dynamic page to be the front page. What is the way to add some javascript to functions.php or index.php or any other file to load a custom page before the dynamic page so the both pages will show on the home page. I have done it a long time ago and do not remember any more. This is the website I did it for http://superforma. The reason I am trying to do it that way is because I am trying to use the templates for the blog style from the theme I am using and do not want to just add the blog section and try to customize. Thank you.

Share Improve this question asked Feb 4, 2017 at 16:27 Svetlozar PopovSvetlozar Popov 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You will need to edit your front-page template and before (or after) your loop, you need to make a call to get_post() so load your custom page. See the documentation for details.

You can then render your customisable page on the homepage.

For example, if your special page ID is 42:

<?php 
   $custom_page = get_post(42);
   echo apply_filters('the_content', $custom_page->post_content);
?>

本文标签: homepageAllow a static page to show on a dynamic home blog page before the posts