Support

Account

Home Forums General Issues Can't send a custom feild in custom post type to email

Helping

Can't send a custom feild in custom post type to email

  • hi,
    I have added in my function.php this line:

    function demo_function( $content ) {
        $someHtml = '<div class="someClass" style="color:red;">';
        $someHtml .= 'HEADER TEXT';
        $someHtml .= get_field('location');
        $someHtml .= get_field('description');
        $someHtml .= 'FOOTER TEXT';
        $someHtml .= '</div>';
    
        $filteredcontent = $someHtml . $content;
    
        return $filteredcontent;
    }
    add_filter( 'the_content', 'demo_function' );

    but it not send value in custom feild. only send HEADER TEXT + FOOTER TEXT. How to fix it?

    Thank,
    Tommy

  • Hi @nhatrangart

    If the get_field function is not returning data, it is most likely that ACF does not know which post to load the data from.

    Can you please debug the value of get_the_ID() within your demo_function?
    Is this ID the expected post’s ID?

    Thanks
    E

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Can't send a custom feild in custom post type to email’ is closed to new replies.