Adding a custom field into the_content()

Try the_content filter to append your field onto the content:

function wpa_content_filter( $content ) {
    global $post;
    if( $meta = get_post_meta( $post->ID, 'reviewGrade', true ) ) {
        return $content . $meta;
    }
    return $content;
}
add_filter( 'the_content', 'wpa_content_filter', 10 );

Use the priority argument of add_filter to control the order in which your function runs.

Leave a Comment