admin管理员组文章数量:1173665
I am trying to create a Custom Premium WordPress theme for a Travel Agency. I am thinking of finishing the theme and submitting it for review.
I want this theme to be really useful so I ended up creating some Custom Post Types (CPT) like :
- Organized Trip : with custom fields(CF) like : Hotel name, Trip Duration,Type of reservation,... .
I honestly agree with those who say for a better code these CPT & CF belong into a Plugin something like **Organized Trip Plugin **.
So should I :
- Make this a separate plugin and pack it into the WordPress theme in a bundle way with TGM Plugin Activation.
Or
- write down these Custom post types into the WordPress theme files and include them in the functions.php - Theme Setup.
Which one do you think is the Best Way to do this?
I am trying to create a Custom Premium WordPress theme for a Travel Agency. I am thinking of finishing the theme and submitting it for review.
I want this theme to be really useful so I ended up creating some Custom Post Types (CPT) like :
- Organized Trip : with custom fields(CF) like : Hotel name, Trip Duration,Type of reservation,... .
I honestly agree with those who say for a better code these CPT & CF belong into a Plugin something like **Organized Trip Plugin **.
So should I :
- Make this a separate plugin and pack it into the WordPress theme in a bundle way with TGM Plugin Activation.
Or
- write down these Custom post types into the WordPress theme files and include them in the functions.php - Theme Setup.
Which one do you think is the Best Way to do this?
Share Improve this question edited Oct 11, 2019 at 8:37 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Oct 10, 2019 at 23:57 AnessAness 1435 bronze badges1 Answer
Reset to default 2You will be rejected from the WordPress.org theme directory if you include these post types in the theme. The guidelines, which are available here, state:
Non-design related functionality is not allowed. (See: Plugin territory examples)
And one of the examples is:
Custom Post Types and Shortcodes
Regarding TGM, the guidelines have this to say:
- Themes cannot include plugins
- Themes cannot require plugins to work
- Themes may recommend plugins from WordPress.org
- Themes may only use TGM Plugin Activation or similar libraries to recommend and install plugins that are hosted on WordPress.org (by using
'required' => false
for each plugin)
So you will not be rejected if you use TGM, as long as your plugin is recommended, and not required.
This is best practice regardless of the directory rules though. If post types are included in the theme, then if the user switches themes they will lose access to their content, because the post types are no longer registered. This should not happen from switching themes. The content may not display correctly in the new theme, but the user will at least still have access to it.
版权声明:本文标题:Should Custom post types and fields be in the theme files or in a custom plugin packed into the theme? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1737579385a1997419.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论