I have a function that is hooked to the end all posts. I’m adding a shortcode so the same function can be called else where. And I need to change the output method based on whether the function was called by a shortcode or the hook.
I have this:
if (did_action('hd_related_posts') > 0) {
// Function was called by the 'hd_related_posts_shortcode' shortcode
return ob_get_clean();
} else {
echo" Function was not called by the shortcode";
echo ob_get_clean();
}
But even when I call the function from the shortcode, this IF
statement returns false and the output is echoed when it should be returned. How do I fix this?