在我的 wordpress 模板中,我设计了一个介绍页面并将其设置为静态页面,现在我想在其中放置一个按钮,当用户单击它时会显示 index.php 的内容。
问问题
1409 次
1 回答
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
*/
?>
现在从页面编辑器中的“页面属性>模板”下拉列表中,您将在下拉列表中看到您的“自定义页面”模板
于 2014-04-14T15:12:30.720 回答