gyrus / WordPress-Developers-Custom-Fields

A plugin to provide WordPress developers with tools for managing custom fields. Check the WP repository link below for the source - GitHub currently only used for issue tracking.
http://wordpress.org/extend/plugins/developers-custom-fields/
51 stars 11 forks source link

Can I add custom field when using get_template_part()? #39

Closed wizzywiggs closed 8 years ago

wizzywiggs commented 8 years ago

I have custom post type but we want to show different layout/design for child pages. We use get_template_part() to pull different template parts. Is it possible to get slt_cf work with this?

For example, when I say get_template_part('product', 'single'), the wordpress will look for template called product-single.php, i fit finds it, it uses it. Will slt_cf identify this as a template or what would be possible solution?...

Thanks so much

gyrus commented 8 years ago

I'm not sure I follow this. How do you see custom fields relating to get_template_part()?

As you know, custom fields in the database are related to individual posts. In terms of this plugin, custom fields can be applied to posts based on their post type, page template (i.e. the template applied to a WP page), and a number of other factors. I don't really see how get_template_part() relates to this though. It's basically just a way of including a partial in a way that can work with child theme overrides.

wizzywiggs commented 8 years ago

Steve, thanks for reply! I have been a long time fan of the plugin :) Yes, that is correct about what you said, the template_part is pretty much way to pull different chunk of template into the page template. That is what I am wondering with slt_cf.

Okay, another way I could ask is this - is there an option in the scope or otherwise to say add these Custom Fields only to the child pages of custom post type called 'product'?

I hope it makes sense, all I am trying to do is only show those fields for sub posts, I dont want to show a bunch of fields on parent pages that will be useless.

Thanks so much!

gyrus commented 8 years ago

Ah, I've not really dealt much with hierarchical custom post types. I think you might be looking at rolling your own scoping with slt_cf_check_scope (check the docs). You can do pretty much anything within that, all necessary data is passed through to help. Let me know if you get stuck with that!

wizzywiggs commented 8 years ago

Okay, I will read on that. Thanks so much! I will definitely hit back if I get stuck!