WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get a custom field to show straight after the main body of text in single.php BUT before the Outbrain and Facebook Connect boxes. If I put the line to show the address above <?php the_content('Read the rest of this entry »'); ?> then it shows above the body text, if I place it below, it doesn't show at all.

Is there any way to insert it into 'the_content'?


share|improve this question

Yes, there is 'the_content' filter. See the codex.

For instance:

add_filter( 'the_content', 'my_the_content_filter', 20 );

 * Add a test to the end of every post page.
function my_the_content_filter( $content ) {

    if ( is_singular('hotels') ){
        //If a single post is being viewed, add something
        //Or get the value of a custom field and append it
        $post_id = get_the_ID();
        $custom_field_value = get_post_meta($post_id, 'Address', true);
        $content .= $custom_field_value;
    // Make sure you returns the content, edited or otherwise
    return $content;
share|improve this answer
Thanks for the reply. Can't get it to work. I must be doing something stupid :)... I am using a post type where single is single-hotels And want to add a custom field called 'Address' after the text... How would it fit in? Thanks – Ben Jan 13 '12 at 22:32
Replace is_single() with is_singular( 'hotels' ) – TheDeadMedic Jan 13 '12 at 22:34
Thanks - I did that but it didnt help – Ben Jan 13 '12 at 22:57
As TheDeadMedic points out, for custom post type 'customtype', you'll want to use is_singular('customtype'). See here – Stephen Harris Jan 13 '12 at 23:12
@Ben, I have made some changes to answer your question. The above should work, assuming the post is of custom type 'hotels'. – Stephen Harris Jan 13 '12 at 23:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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