0

I have searched high and low and none of the solutions I have found have worked for me.

I have created a custom post type call Testimonials and I have created two new custom post fields called testimonial-author and testimonial-company (these are both stored in the postmeta database table).

I would like to use a shortcode to display these on the post page along with the testimonial text.

Can anyone please help me with the code?

add_shortcode('testimonial_author', 'testauth');

function testauth($atts) {
    global $post;

    return get_post_meta($post->ID,'testimonial-author',true);

}

1 Answers1

0

I used this code instead and it works now:

//Testimonial Author
function test_auth_shortcode($attr) {
    global $post;
    return get_post_meta($post->ID,'testimonial-author', true);
}
add_shortcode('test_auth', 'test_auth_shortcode');