Child theme are loaded first than parent theme. And unlike other template files functions.php
of child theme get merged with parent theme’s functions.php
instead of being overwritten.
So a function i.e. et_pb_blog()
declared in parent theme can not be re-declared in child theme.
Solution:
- Remove the shortcode in child theme
- Add it again with child theme but with different callback function name.
- You are buffering content but not returning what is in buffer. So complete the code with returning buffered content.
Example:
/* Remove shortcode that was added in parent them */
remove_shortcode('et_pb_blog');
add_shortcode('et_pb_blog', 'et_pb_blog_custom');
/**
* Add the shortcode again with diffrent function name
* @return string $shortcode_content
*/
function et_pb_blog_custom($atts) {
ob_start();
//Do watever you want
$content = ob_get_contents(); //Get the buffer contnet
ob_end_clean(); // turn off buffering
return $content; // Return the content
}
Suggestion: Never use
query_posts()
instead try to useget_posts()
or mostly preferredWP_Query()
. Continue reading here