Support

Account

Home Forums Front-end Issues Feed tag based on ACF checkbox value

Unread

Feed tag based on ACF checkbox value

  • I have a ACF checkbox field set up (‘kiemelt_cikk). I’m trying to add a custom tag in the WordPress RSS feed, that appears only, if the field is ticked.

    The issue is that while the tag gets added, it gets added to all of the fields, despite it being ticked or not.

    function add_acf_value_to_post_feed() {
    global $post;
    $kiemelt = get_field( ‘kiemelt_cikk’, $post->ID );

    $output = ”;
    if ( !empty($kiemelt) ) {

    $output .= ‘<hst:titlepage>’;
    $output .= ‘1’;
    $output .= ‘</hst:titlepage>’;
    }
    echo $output;
    }
    add_action( ‘rss2_item’, ‘add_acf_value_to_post_feed’ );
    I tried a couple of alterations, such as leaving the condition only as:

    if ( $kiemelt ) if ( $kiemelt == true )

    But none of these seems to do the job. What am I missing? Thanks!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.