2018-10-22 10:56
浏览 74


I'm facing a big issue with the right way of implementing the static page in Wordpress. I've read almost for 5 days along now, and still can't figure out how it (should) work.

The problem i'm facing is as followed:

When I make use of the option "show latest posts" in customizer, I see the front page as it should be. I got the text of the homepage followed by the latest posts. The problem I'm facing here, is the homepage text is hard coded in my home.php. I want to be able to change that on the input field of the home in my wordpress editor.

So I understood i should make use of the index.php and create a page called "Home" and a page called "Blog". I set those pages as static page, and i'll be able to accomplish what I want. But i don't. I just can't get it done.

So I tried it with a complete new installation of WP in my local machine. Setup a brand new installation, created just 2 pages (home and blog). Go to Settings-> Reading -> Set static page: Homepage: Home Post page: Blog. Saved changes.

Got to the homepage and i just saw my homepage. No posts up there.

What am i missing here?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanchun1909 2018-10-22 11:05

    You are using a page called "Home" which is empty. It's expected and is fine. What you really need is to create a custom template (, and create any custom layout you want

    Extended Answer

    Create a template called homepage.tpl.php for example. Put this code inside:

     * Template Name: Custom Homepage
    get_header(); ?>
      if ( have_posts() ) :    
         while ( have_posts() ) : the_post();
      $wp_query = new WP_Query(array(
        'post_type' => 'post',
        'post_status' => 'publish'
      if ( $wp_query->have_posts() ) :
        while ( $wp_query->have_posts() ) : $wp_query->the_post();
          /* Post loop content goes here */    
    <?php get_footer(); ?>

    Go the admin panel -> pages -> click edit "home". At the right sidebar select the template called "Custom Homepage". That's it.

    解决 无用
    打赏 举报

相关推荐 更多相似问题