0

There is a very poor coding practice among freelancers that they create individual pages for every custom post types, but I think there is a better way to do this by Creating functions in functions.php and then calling those functions.

For any Function/meta created in functions.php, how to integrate or call that function for Custom Post types?

I am unable to Understand the basic logic can come one explain.

EDIT from comments

....my question was suppose there is a meta created for BIG text (Through Function)and now we have 10 custom post types and we want this meta to be shown in 5 CPT's then w/o repeating the codes how can we build function and attach it to those custom post types?

  • 2
    Your question does not really make sense. – Pieter Goosen Feb 27 '16 at 9:34
  • Also, custom post types should be registered in a plugin, and not in a theme – Pieter Goosen Feb 27 '16 at 9:34
  • I Know that CPT should be registered in plugin, but my question was suppose there is a meta created for BIG text (Through Function)and now we have 10 custom post types and we want this meta to be shown in 5 CPT's then w/o repeating the codes how can we build function and attach it to those custom post types? – The WP Intermediate Feb 27 '16 at 9:50
  • 1
    Different templates for different post types is perfectly normal and encouraged. Parsing and processing one 500-liner template is much more efficient than parsing very huge functions.php + CPT should be added via plugin which means that if you disable the plugin, template doesn't eat resources for no reason but if you have everything in functions.php, it will still have to parse it. None of the files (not even functions.php) should be huge. – N00b Feb 27 '16 at 11:00
  • Are you talking about custom post type archives or single custom post type posts – Pieter Goosen Feb 27 '16 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.