Hello Fellow WordPressers,
I have what may be a bit of a philosophical question: When adding custom functionality to your site, is it better to use conditional tags or create a new template (either named based on the Template Heirarchy or custom page template)?
For instance:
Say I've added a custom post type, "custom". I want to do some cool stuff with both its "single" page and it's "archive" page.
From a Coding Best Practices standpoint
a) is it better to write a function in functions.php such as:
// Customize Custom Post Type
add_action('wp-head', 'my_custom_function');
function my_custom_function(){
if (is_post_type_archive('custom')){
"Do custom stuff like replace loop, etc"
}
}
or
b) should I create a separate archive-custom.php file (or single-custom.php, etc) and do all the customization there?
---
I tend to do both, but as I'm constantly trying to improve the efficiency of my coding, I'm wondering if there's a "Best Practices" approach I should follow.
Does anyone have an opinion either way?
Thanks,
-Jason Chafin