0

I'll try my best to explain what I'm trying to achieve. I haven't been developing with Wordpress for a while and I've hit a bit of a wall.

I'm looking to get into making Premium Wordpress Themes. Each theme is going to consist of custom post types (e.g. portfolio, slideshow, events). I'm trying to create a SINGLE plugin which holds these custom post types and only includes the custom post types the theme uses.

E.g. a theme may only use the portfolio custom post type. I'm achieving this so far by adding this to the themes function.php file.

add_theme_support( 'custom_portfolio' )

Then, within the plugin, i'm using:

require_if_theme_supports( 'custom_portfolio', PLUGINROOT . '/inc/post-types/portfolio.php' );

I'm trying to make these themes not 'lock' the user in. If they are to change themes, the custom post types are still visible, so they can accesss the data, even if they may not work accordingly. Obviously, the custom post types will fail to load because the theme won't have support for 'custom-portfolio'.

How can I achieve this?

Thanks.

3 Answers 3

0

Let your plugin create a management page where the user can activate the different custom post types.

Highlight the post types that the current theme supports, and explain what exactly that means.

It could look like this:

    Post type         Support by Your Cool Theme Name
[x] Portfolio         Template, search, custom editor fields
[x] Event             Not supported
[ ] Project           Template, search, can be set as front page
0

The Custom Post Type won't fail to load just because your theme won't have support for 'custom-portfolio' if you define CPT in your plugin.

There is always single.php which will be used if no other template is found. You can provide at least minimal css support from your plugin so that the content is understandable even if they switch theme.

You can also provide template from your plugin if there is no specific template exist for that Custom Post Type. It won't match the new theme all the way, but at least it will be accessible.

If the users use your theme, template from your theme will be used and you can provide the best possible look from there.

I think it's the best you can do to prevent user from being 'locked in'.

0

-1 to the whole idea

Breaking up your theme into two parts and calling one of them "plugin" do not solve the theme lock in problem. As long as there is only one theme that can access the CPT content there is a lock in even if in theory others themes can access it.

A good CPT in a plugin should be self contained and work across all themes without requiring the theme to do anything special to invoke the functionality. bbpress and woocommerce are probably two good examples for that.

As long as you need to do something like add_theme_support( 'custom_portfolio' ) to use the plugin properly there is a lock in and you might as well save yourself the trouble and keep the CPT as part of the theme.

2
  • Thanks Mark, I agree with what you are saying. The main problem it solves is the fact that I only have to update one plugin and it'll be available across all the themes. The reason I have to invoke the functionality is because some themes won't support certain CPT's. By 'lock in', I mean giving the user the ability to at least see the CTP in the back end with all the data, even if it isn't going to work on the front end. Otherwise people will assume the data is actually lost, when in fact it isn't.
    – Stephen
    Aug 16, 2014 at 6:59
  • so the user will update a plugin and it might impact the way the site's front end works without giving any explicit or implicit warning. This is a truly bad bad idea. Aug 16, 2014 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.