Answer the question
In order to leave comments, you need to log in
Display in Wordpress RSS only those posts that have the value of the custom field "add_in_rss" assigned, how?
Good day
Please tell me how in WordPress to show in the RSS feed only those posts that specify the value of a custom field, for example, add_in_rss and the value yes for it.
So that all published / updated articles do not get into the RSS, but only the specified ones. Such custom RSS will turn out in the end.
Found this code :
// Loop starts here
while (have_posts()) : the_post();
// Get the meta field
$meta = get_post_meta($post->ID, "Meta Name", false);
// Do no show post if the meta equals "Meta Value"
if($meta != "Meta Value"){
// Content Here
}
endwhile;
// Loop ends
...do_action( 'rss2_head' );
while ( have_posts() ) :
the_post();
$meta = get_post_meta($post->ID, "add_in_rss", false);
if($meta = "yes"){
?>
<item>
<title><?php the_title_rss(); ?><....
....
....p echo get_comments_number(); ?></slash:comments>
<?php endif; ?>
<?php rss_enclosure(); ?>
<?php
/**
* Fires at the end of each RSS2 feed item.
*
* @since 2.0.0
*/
do_action( 'rss2_item' );
?>
</item>
<?php } endwhile; ?>...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question