Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.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
Php 来自一个特定短代码的WordPress RSS源_Php_Wordpress_Function_Rss_Shortcode - Fatal编程技术网

Php 来自一个特定短代码的WordPress RSS源

Php 来自一个特定短代码的WordPress RSS源,php,wordpress,function,rss,shortcode,Php,Wordpress,Function,Rss,Shortcode,我想使功能,将显示RSS提要内容从一个特定的短代码。 例如,我有: [text1]Text One[/text1] [text2]Text Two[/text2] 现在,text2短代码的内容应该显示在RSS提要中 到目前为止,我的职能是: function custom_rss($content) { if(is_feed()){ $content = "Custom Text"; } return $content; } add_filter('the_excerpt_rss', 'cus

我想使功能,将显示RSS提要内容从一个特定的短代码。 例如,我有:

[text1]Text One[/text1]
[text2]Text Two[/text2]
现在,text2短代码的内容应该显示在RSS提要中

到目前为止,我的职能是:

function custom_rss($content) {
if(is_feed()){
$content = "Custom Text";
}
return $content;
}
add_filter('the_excerpt_rss', 'custom_rss');
add_filter('the_content', 'custom_rss');
好的,这样就行了,我在RSS提要中得到了“自定义文本”

什么函数将调用特定短代码中的内容,例如从
[text2]Text Two[/text2]
Wordpress Codex:

请尝试以下代码:

function text( $atts, $content = null ) {
    if (is_feed()) {
        return $content;
    } else {
        return '<div class="text" style="display: block; margin-left: 160px;">'.$content.'<br><br></div>';
    }
}
add_shortcode( 'text', 'text' );
函数文本($atts,$content=null){
if(is_feed()){
返回$content;
}否则{
返回“.$content.”

; } } 添加_短代码('text','text');
如果您只想在提要中显示短代码,请阅读@pfefferle,我不需要新的短代码,而是将现有代码提取到此函数中。我已经有了[text2]短代码,现在我想把它的内容调用到rss。对于每个帖子,都有[text2],对于rss中的每个帖子,都应该提取text2短代码的内容。短代码也适用于rss提要。如果您已经正确地实现了短代码,那么就没有更多的事情要做了。请参阅@avi am对所有内容使用短代码的评论,它们将从RSS提要中剥离/删除。我的提要只显示标题,而不是评论。没有内容。这就是为什么我要找这个。你能分享短代码吗?我检查了所有的函数,没有一个可以从rss中删除短代码,但是,你的函数我有它:。尝试在仪表板中更改为完整内容,但仍然是一样的。
function text( $atts, $content = null ) {
    if (is_feed()) {
        return $content;
    } else {
        return '<div class="text" style="display: block; margin-left: 160px;">'.$content.'<br><br></div>';
    }
}
add_shortcode( 'text', 'text' );