This is general question but lets say I have a function and on a specific page I want to display a table.
The function only applies to one page on my site but every post/page will run this function (and skip it when it ‘realises’ it isn’t the right page).
Would it be better, from a performance point of view, to use a page template for this specific page instead of this filter? Or is this negligible and not worth worrying over.
Hopefully you get the gist of what I’m asking, I realise there are
other factors like how my table (or whatever I’m including) is
processed but lets ignore that for the sake of this question.
add_filter('the_content', 'str_load_table');
function str_load_table($content) {
if(is_page('my-table')) {
$my_content="pretend this is a table";
$content = $content . $my_content
}
return $content;
}