douwayuan3063 2017-02-02 07:24
浏览 180

自定义WordPress模板仅加载页眉和页脚

I have a weird problem. I'm trying to make custom template for WordPress. index.php works perfectly fine - everything what should load, loads with no problems.

index.php:

<?php get_header(); ?> 
<?php if ( is_home() &&function_exists('get_template_part')) get_template_part( 'content', get_post_format() );?>
<?php get_footer(); ?>

But when I create a new page, like promotions.php and put custom code, It does not show up on the page. I can see only header & footer section. It looks like I didn't put any code at all.

  • 写回答

2条回答 默认 最新

  • drrog9853 2017-02-02 07:53
    关注

    You can make custom page templates like so

    <?php
     /**
       * Template name: custom-name
       */
    
      get_header();
      if (is_home()) {
        get_template_part('content', get_post_format());
      }
       get_footer(); ?>
    

    And then inside WordPress you can edit the page. On the right side below publish you can see default template. Choose your template and hit save.

    Edit:

    See the image below for further instructions.

    enter image description here

    评论

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services