Anyway to add a custom field into the_content() somehow?

I have the AddThis plugin on my site and it shows up at the bottom of my site right before my custom field, I would like my custom field to show up at the very end of the_content() and then have the AddThis stuff show up.

Anyway to do this?

  • 1
    how is the custom field added at the moment? – Michael Jun 9 '13 at 16:23
  • Like this, <?php echo get_post_meta($post->ID, 'reviewGrade', true); ?> right after the_content() – Richard Jun 9 '13 at 16:37

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.