You can do this by overriding the pluggable function cpotheme_postpage_image()
.
A pluggable function is such a function which you can override in your child theme. A pluggable function is always enclosed inside a condition like
if(!function_exists('pluggable_function_name')) {
//declare the function here
function pluggable_function_name() {
//function body here
}
}
So if you write a function with the same name in your child theme’s functions.php
file like this:
function pluggable_function_name() {
//function body here
}
WordPress will not execute the function in the parent theme and your function will be taken into precedence.
In your case the plugabble function is cpotheme_postpage_image() which is originally written as
function cpotheme_postpage_image(){
if(has_post_thumbnail()){
if(!is_singular('post')){
echo '<a href="'.get_permalink(get_the_ID()).'" title="'.sprintf(esc_attr__('Go to %s', 'allegiant'), the_title_attribute('echo=0')).'" rel="bookmark">';
the_post_thumbnail('portfolio');
echo '</a>';
}else{
the_post_thumbnail();
}
}
}
which you need to override in your child theme’s functions.php
file like this:
function cpotheme_postpage_image(){
if(has_post_thumbnail()){
if(!is_singular('post')){
echo '<a href="'.get_permalink(get_the_ID()).'" title="'.sprintf(esc_attr__('Go to %s', 'allegiant'), the_title_attribute('echo=0')).'" rel="bookmark">';
the_post_thumbnail('portfolio');
echo '</a>';
}else{
echo '';
}
}
}
meaning if this is single post, the function outputs empty string (echo '';
) and does not print the_post_thumbail();
, i.e. the featured image.
Let me know if this helps.