Wordpress:如何在页面编辑视图中显示部分静态内容

时间:2020-12-19 08:13:30

标签: php html wordpress wordpress-theming custom-wordpress-pages

我正在使用 wordpress 从主题 220 中自定义一个新主题。

在每个页面的开头(不是post),会有一个全屏英雄页面(部分静态页面),后面是wordpress创建的原始可编辑页面。

我在文件夹“template-parts”中创建了一个“hero-image.php”。使用 get_template_part( 'template-parts/hero-image', get_post_type() ); 使原始模板读取此部分内容。

这是菜单栏的截图: enter image description here

'customize' 选项现在有这样的预览。 enter image description here

但是,当我选择“编辑页面”选项时,预览看起来像这样。 enter image description here

问题是,在“编辑页面”选项中,英雄图像消失了。因此,如果用户从此视图编辑页面,则编辑视图的开头将永远不会显示。

我想要做的是让我的静态英雄图片 html 显示在“编辑页面”选项中。它们不需要可编辑。它们只需要显示在“编辑页面”中即可。

我已经检查过 post.php 和 edit-form-b​​locks.php。将我的静态 html 直接添加到这两个文件中会使编辑视图看起来很奇怪。我想我应该修改 wordpress 中的原始 $post 并将我的静态英雄图像代码添加到这个变量中。但是,我找不到这样做的详细手册。

任何人都可以提供一些建议来实现我想做的事情吗?

※ 我查了这个帖子: Adding static content to Wordpress posts page?

但我不知道 get_option() 的参数是什么。而且我不知道它是否适用于我的情况。

0 个答案:

没有答案
相关问题