Tagged: custom post types
I have code for displaying a custom post type currently in the functions.php file – I’m wondering if I can move it to a template for the single-(post-type).php instead (single-tipoftheday.php in this case). I will have several other CPT’s to format and think this will make it easier for the client to eventually modify these if they need to. Will those functions still work that way? Here is a paste of what I expect the template would be.
(Displaying the custom fields works in functions.php – I’m not necessarily asking for a review of THAT – but rather if it will continue to work as a template instead of in functions, and if this is a good practice).
Not sure if I understand correctly, but it’s too late to register the CPT by the time you’re in a template page.
I’d pull all the CPTs out into a single file (call it my-theme-cpts.php or something equally obvious) and then include that file in functions.php. It’ll keep your code a little cleaner.
Then you can still do your template files as is, except you won’t need the conditionals (i.e. no need to check if it’s a single page if you’re already in single-tipoftheday.php.
I may have completely missed your question. If so, try me again.
I already have the CPT’s defined (using the Custom Post Type UI plugin so the clients can more easily manage them in the future).
@Carrie – so the rest of the paste, minus the conditional to check for the CPT, the it would work as it is in single-tipsoftheday.php ?
I’ve got the entire part about displaying custom fields in the functions.php file now.
You must be logged in to reply to this topic.
Are you a blogger, web designer, developer, or website owner looking to generate more income?
Promote products for the largest and fastest growing online website platform as part of our affiliate program.