You mostly got everything right. But the code you posted also gave an error caused by an ’
char in your code.
add_filter ('the_content', 'references');
function references( $content ) {
// only run the code on singular views of the post type "my_custom_post_type"
if( is_singular('my_custom_post_type') ) { // insert your custom post type here
// get current post ID
$post_id = get_the_ID();
// get your custom field here using what you need;
// maybe use: get_post_meta( $post_id, 'custom_field_name');
// you showed a shortcode, than maybe use:
// do_shortcode('[acf field="custom_field_name"]');
$custom_field = get_post_meta( $post_id, 'custom_field_name');
$content.= '<h3>References</h3>';
$content.= $custom_field;
$content.= '<a href="https://***.com/sources">Read more about our sources</a>';
}
return $content;
}
For example if you replace my_custom_post_type
with product
(the WooCommerce post-type) you will only see this content on single product pages.
You should put this code inside your functions.php or better, inside a plugin.