php - 在functions.php的标题下方添加横幅
问题描述
我正在尝试在所选页面的标题下方添加横幅/内容。我尝试了下面的代码但没有工作:
add_action ('__after_header' , 'add_content_after_header', 20);
function add_content_after_header() {
//checks if we are displaying the home page
if ( !tc__f( '__is_home' ) )
return;
?>
<div id="my-content-header">
<p>Content</p>
</div>
<?php
}
然后我尝试了另一个代码,它正在工作但在标题顶部显示内容:
add_action ('wp_head' , 'add_content_after_header', 20);
function add_content_after_header() {
//checks if we are displaying the home page
global $post;
if ($post->post_type == 'page' && $post->ID == '7')
return;
?>
<div id="my-content-header">
<p>Content</p>
</div>
<?php
}
基本上“__after_header”操作对我不起作用,但“wp_head”操作显示标题顶部的内容。任何想法如何解决这个问题并将内容放在标题下方?
解决方案
推荐阅读
- jquery - 问题多词使用jquery和json实时搜索
- reactjs - 如何让算法对每个输入只搜索一次?
- cakephp - 如何在 cakephp shell 中运行单元测试脚本?
- python - Getting Syntax Error in Keyword Class Patterns
- wpf - 使用 ComboBox 设置源列表中的字段值
有两个值 - WPF - c# - 如何强制 Visual Studio 2019 为 ClickOnce 部署/安装的图标生成 .deploy 文件
- javascript - 无法在 DynamoDB DocumentClient 中实现分页
- c# - MS Project - 如何获取外部依赖任务的唯一 ID?
- redis - 如何使用 tile38 检索字段值?
- python - Selenium for Python - 如何进入另一个内部