Answer the question
In order to leave comments, you need to log in
Display a post in WordPress RSS only if it has a custom field value entered, how to do it?
Good day
, Please tell me how in WordPress to show in the RSS feed only those posts that have a custom field value, for example, rss-on and a value of 1 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.
I found this code here :
// 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
while ( have_posts() ) :
the_post();
?>
<item>
<title><?php the_title_rss(); ?></title>
<link><?php the_permalink_rss(); ?></link>
<?php if ( get_comme...
...
.....ments_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