如何在标题标签(wordpress)之后回显某些内容?

时间:2019-06-17 21:30:04

标签: wordpress

我想在单页的页眉标记后回显某些内容。

我有一个过滤器,可以在内容之前添加一些内容。

function add_custom_meta_to_content($content) {   
    $queried_object = get_queried_object();

    if ( $queried_object ) {
        $post_id = $queried_object->ID;
    } 
    $text = get_post_meta($post_id, 'textbox_wporg_meta_key', true);
    if( is_single() ) {
        $content = $text . '' . $content;
    }
    return $content;
}
add_filter( 'the_content','add_custom_meta_to_content' );

但是现在我想通过插件在页面的标头标记后添加一些数据。

我不想编辑主题代码。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

通常不会使用the_content过滤器执行此操作。几乎所有的商业主题都有一个特定的钩子,可以在帖子标题之后和主要内容之前插入其他代码。例如,Generatepress框架将使您能够钩入generate_after_entry_title动作钩子,并在那里输出其他代码。