我可以在发布内容之前添加内容而不使用 the_content 过滤器吗 [英] Can I add content before post content without using the_content filter

查看:27
本文介绍了我可以在发布内容之前添加内容而不使用 the_content 过滤器吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在添加过滤器以在发布内容之前添加嵌入,但不想添加到称为 apply_filters("the_content") 的其他地方.

I am adding filter to add embed before post content, but don't want add to other places where called apply_filters("the_content").

所以我需要在没有the_content"过滤器钩子的情况下在发布内容之前(之后)添加嵌入.

So i need add embed before(after) post content without "the_content" filter hook.

add_filter('the_content', 'embed_on_post');

推荐答案

如果您只想过滤某种类型或此类,您可以在过滤器功能中添加您的验证:

if you want to filter only a certain type or such, you can add your verification inside your filter function:

来源:wordpress 文档

add_filter( 'the_content', 'my_function' ); 

function my_function( $content ) {
    //for a single post
    if (is_singular('post')) {
        /* do whant you want */
    }

    //or also (works for posts except attachments and pages)
    if (is_single()){

    }

    return $content;
}

这篇关于我可以在发布内容之前添加内容而不使用 the_content 过滤器吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆