Discussion:
Allowing theme to override plugin markup on data
Tom Barrett
2013-11-07 15:45:31 UTC
Permalink
I'm writing a shortcode that is going to produce a list of items (oof!).
It's a custom post type, with some meta. Pretty much a standard loop
scenario.

I'd like the shortcode to produce some basic output, and let the theme
really jazz things up. Ideally I'd have the data available with no markup
(for the theme) and then, if the theme doesn't do anything, let the plugin
apply some simple markup of it's own.

Any recommendations on how to engineer this the best?
--
http://www.tcbarrett.com | http://gplus.to/tcbarrett |
http://twitter.com/tcbarrett
John
2013-11-07 18:17:17 UTC
Permalink
I've done this by checking if a template exists in the theme directory,
using locate_template( 'single-post-type.php' ), and if not loading
template parts from the plugin dir and/or filtering the_content. The
assumption being, if the theme isn't handling the custom post type template
stuff, my plugins needed to.

bbPress has a good example of modifying the template stack and loading them
from the plugin dir if they don't exist in the child or parent theme
directories. I think the function is named bbp_locate_template. See also
bbp_get_template_part.
Post by Tom Barrett
I'm writing a shortcode that is going to produce a list of items (oof!).
It's a custom post type, with some meta. Pretty much a standard loop
scenario.
I'd like the shortcode to produce some basic output, and let the theme
really jazz things up. Ideally I'd have the data available with no markup
(for the theme) and then, if the theme doesn't do anything, let the plugin
apply some simple markup of it's own.
Any recommendations on how to engineer this the best?
--
http://www.tcbarrett.com | http://gplus.to/tcbarrett |
http://twitter.com/tcbarrett
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Tom Barrett
2013-11-08 14:22:38 UTC
Permalink
Thanks John

I can see the bbPress does some clever stuff with making their own template
stack.

I think I'll try something with filters and hope that
http://core.trac.wordpress.org/ticket/22355 gets to see the light of day :)
Post by John
I've done this by checking if a template exists in the theme directory,
using locate_template( 'single-post-type.php' ), and if not loading
template parts from the plugin dir and/or filtering the_content. The
assumption being, if the theme isn't handling the custom post type template
stuff, my plugins needed to.
bbPress has a good example of modifying the template stack and loading them
from the plugin dir if they don't exist in the child or parent theme
directories. I think the function is named bbp_locate_template. See also
bbp_get_template_part.
Post by Tom Barrett
I'm writing a shortcode that is going to produce a list of items (oof!).
It's a custom post type, with some meta. Pretty much a standard loop
scenario.
I'd like the shortcode to produce some basic output, and let the theme
really jazz things up. Ideally I'd have the data available with no markup
(for the theme) and then, if the theme doesn't do anything, let the
plugin
Post by Tom Barrett
apply some simple markup of it's own.
Any recommendations on how to engineer this the best?
--
http://www.tcbarrett.com | http://gplus.to/tcbarrett |
http://twitter.com/tcbarrett
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
--
http://www.tcbarrett.com | http://gplus.to/tcbarrett |
http://twitter.com/tcbarrett
Loading...