I have a shortcode that outputs null ("").
What I'm trying to accomplish is to output a default message if the shortcode outputs null. I don't want to extend my shortcode because there may be multiple instances of the shortcode and I don't want to output the message multiple times.
So my function is as follows:
function av_standalone_doc_404($content) {
if(has_term('standalone-document', 'formats')){
$filtered_content = apply_filters('the_content', $content);
if(empty($content)){
// Display 404 message
$output .= '<div id="404_message">Error:
Please check this page later.</div>';
}else{
$output .= '';
}
return $output . $content;
}
}
add_filter('the_content', 'av_standalone_doc_404', 12);
The problem is that apply_filters
is causing a fatal error - obviously because you can't apply a filter to the content and call apply_filters
within that filter.
The '12' load order doesn't appear to help either.
How can I apply the filter after the subsequent filters which apply the shortcode to the_content
?