Output the_title() inside the_content()

I’m sure this isn’t possible but thought I’d ask.

I have a testimonials section, the html of each testimonial is like so

    <p>
      the testimonal here blah, blah, blah, blah, blah, blah, blah, blah
      <em>Name of person</em>
    </p>

Now in WP I have the testimonials as a Custom post type. The Name of person is the title and the testimonial is the content.

Can I output the testimonial post so it’s like the html.

So it would be the_title inside a ’em’ which is inside the ‘p’ of the_content.

I know I could add the name inside the content in wordpress and then make that italic but I know the client wouldn’t like doing this.

4 Answers
4

You could achieve that with a filter on the_content:

function my_the_content_filter( $content ) {
    global $post;
    if( 'testimonial' == $post->post_type )
        $content .= ' <em>' . $post->post_title . '</em>';
    return $content;
}
add_filter( 'the_content', 'my_the_content_filter', 0 );

Leave a Comment