【问题标题】:How to link to index.php from static page in wordpress?如何从 wordpress 中的静态页面链接到 index.php?
【发布时间】:2014-04-14 14:56:21
【问题描述】:
在我的 wordpress 模板中,我设计了一个介绍页面并将其设置为静态页面,现在我想在其中放置一个按钮,当用户单击它时会显示 index.php 的内容。
【问题讨论】:
标签:
wordpress
wordpress-theming
frontpage
static-pages
【解决方案1】:
index.php 是通过 Wordpress 使用的默认模板。
见https://codex.wordpress.org/Template_Hierarchy
只需创建另一个页面并确保使用的页面模板是“默认模板”并在需要时链接到该页面。默认情况下应使用 index.php 模板。
如果您有 page.php 模板,它将覆盖 index.php。因此,在这种情况下,复制 index.php 文件,重命名为 page-custom.php 之类的名称,并将以下代码添加到模板文件的第一行。
<?php
/*
Template name: Custom Page
*/
?>
现在从页面编辑器中的“页面属性 > 模板”下拉列表中,您将在下拉列表中看到您的“自定义页面”模板