wordpress Post 与 Page 使用同一个模板的方法

文章目录

    很多时候,我们希望 Page 与 Post 共用一套模板,除了需要定制化的 Page 之外。

    参考 single post 与 single page 遵循的模板名规则顺序可知,使用 singular.php 作为模板名,即可使 Post 与 Page 共用同一个模板。

    single Post 的模板名规则顺序

    1. single-{post-type}-{slug}.php
    2. single-{post-type}.php
    3. single.php
    4. singular.php
    5. index.php

    single Page 的模板名规则顺序

    1. custom template file
    2. page-{slug}.php
    3. page-{id}.php
    4. page.php
    5. singular.php
    6. index.php

    参考