Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress让index.php和single.php显示相同的内容_Php_Wordpress - Fatal编程技术网

Wordpress让index.php和single.php显示相同的内容

Wordpress让index.php和single.php显示相同的内容,php,wordpress,Php,Wordpress,我有一个自定义的博客页面www.example.com/blog 在index.php中,我把所有的代码都放在了博客文章中。当用户单击其中一个博客项目时,它会转到single.php。single.php中的代码是index.php的精确副本 我怎样才能让index.php或single.php调用另一个,这样我就不需要每次编辑时都将相同的代码复制/粘贴到两个文件中(如果我记得这样做的话)。我认为您没有正确使用wordpress 在你的情况下,我会创建一个短代码,并把它放在你想要的任何地方 短代

我有一个自定义的博客页面<代码>www.example.com/blog

index.php
中,我把所有的代码都放在了博客文章中。当用户单击其中一个博客项目时,它会转到
single.php
single.php
中的代码是
index.php
的精确副本


我怎样才能让index.php或single.php调用另一个,这样我就不需要每次编辑时都将相同的代码复制/粘贴到两个文件中(如果我记得这样做的话)。

我认为您没有正确使用wordpress

在你的情况下,我会创建一个短代码,并把它放在你想要的任何地方

短代码信息

清理index.php和single.php,并使用WP admin创建带有该短代码的页面/帖子


关于,Bjorn

如果您在法典中查找文件的层次结构……您将看到Index.php将在没有single.php可用时用于single.php

因此,如果两者的代码完全相同,只需删除一个名为“导入”或“包含”的.php代码即可。您可能需要阅读php文档并自己查找。