php - Include only posts with meta key “add_in_rss” in RSS Feed

I edited this file like this, but it doesn't work...do_action( 'rss2_head' );while ( have_posts() ) :the_

I edited this file like this, but it doesn't work

    ...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; ?>...

What is the mistake, how should it be right?

I am not a programmer. I entered this based on this code only removed the exclamation mark so that there would be a reverse trigger.

Sorry for My English.

I edited this file like this, but it doesn't work

    ...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; ?>...

What is the mistake, how should it be right?

I am not a programmer. I entered this based on this code only removed the exclamation mark so that there would be a reverse trigger.

Sorry for My English.

Share Improve this question edited Feb 7, 2020 at 14:39 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Feb 7, 2020 at 12:29 UserDominUserDomin 1
Add a comment  | 

1 Answer 1

Reset to default 1

Change if($meta = "yes") to if($meta == 'yes'). Your way is setting the variable to yes, so it's always yes; the double equals symbol means to test for a condition rather than set it.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744769002a4592641.html

相关推荐

  • php - Include only posts with meta key “add_in_rss” in RSS Feed

    I edited this file like this, but it doesn't work...do_action( 'rss2_head' );while ( have_posts() ) :the_

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信