Reputation: 305
I want to make function that will display RSS Feed content from one specific shortcode. Example, I have:
[text1]Text One[/text1]
[text2]Text Two[/text2]
Now, content of text2 shortcode should display in RSS Feed.
Function I have so far:
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');
Ok, this works, I get "Custom Text" in the RSS Feed.
What function will call content from specific shortcode, in example, from [text2]Text Two[/text2]
.
Upvotes: 0
Views: 445
Reputation: 503
Try this code:
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' );
Upvotes: 1
Reputation: 519
Wordpress Codex:
shortcode atts and add_shortcode
function bartag_func( $atts ) {
extract( shortcode_atts( array(
'foo' => 'no foo',
'baz' => 'default baz'
), $atts ) );
return "foo = {$foo}";
}
add_shortcode( 'bartag', 'bartag_func' );
Upvotes: 1