dongxun7962 2015-07-27 10:00
浏览 61

将整个页面克隆到自定义index.php

I am building a custom index.php file in my child theme overriding the default theme index.php file which loads first when the theme is first installed.

Is there a way to clone an entire page to index.php file by page name or id or slug? I will build a page by adding a new page from dashboard and add elements there. Now, when I build the page, I also want the index.php file look the same. Hope I make sense.

I have created a custom template as the index.php file. But not sure about the cloning process. Any help will be appreciative.

thanks

  • 写回答

2条回答 默认 最新

  • dte29947 2015-07-27 10:24
    关注

    You can get the code from page.php of your parent theme inside your index.php - in this file you'll have all that is needed to display a page. For example in WP default theme, this code from page.php will display the current page using content-page.php template :

    while ( have_posts() ) : the_post();
        get_template_part( 'content', 'page' );
        endif;
    endwhile;
    

    Then, in WP settings, define your page as home page in Settings > Reading - it will tell wordpress to use that page for your index.php template.

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line