1

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.org. 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.

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);
?>
  • Hi there, thank you for the response. I am trying not to use front-page.php and have setup wordpress to show blog on a front page instead of front to be a template page so I am assuming that index.php should be in charge of what is showing on that page. So am trying to add a static page I have designed in wordpress to that front dynamic blog page. I tried to use your advice but adding it to index.php and it didn't work by using the id of the static page. – Svetlozar Popov Feb 4 '17 at 18:18
  • check here letchowebs.com/Test2.png – Svetlozar Popov Feb 4 '17 at 18:25
  • My mistake - you need to change the echo line to use $custom_page rather than $post. If that fails, can you please do a var_dump($custom_page); and show the output? – Alexander Holsgrove Feb 5 '17 at 1:00
  • Hey Alex, I have tried your recommendation but it didn't work . Unfortunately I am not familiar with the var_dump function since I haven't done it for a long time so I wasn't able to add it . Just to make sure I am doing the right thing , I am adding custom page function to the index.php file. – Svetlozar Popov Feb 5 '17 at 15:00
  • check here: letchowebs.com/test2.png – Svetlozar Popov Feb 5 '17 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.