How to Add Custom Options to the PTU WordPress Plugin

- Advertisement -


The Post Types Unlimited (PTU) plugin is a valuable tool for WordPress site owners who want to add custom post types and taxonomies to their website. Created as a lightweight alternative to other bloated plugins, PTU provides an easy and efficient way to integrate custom types and taxonomies into your site’s design.

One of the key advantages of adding custom options to the PTU plugin is that it allows users to have more control over the design of their custom post types and taxonomies. This is particularly beneficial for theme developers who want to provide their users with the ability to customize the appearance of their content.

- Advertisement -

For example, the Total Theme includes a feature that allows users to modify the single post page header title, select a template for the single post display, choose a layout for the single post type posts, and enable or disable the next and previous links at the bottom of the post. These options give users the flexibility to create unique and personalized single post pages without needing to rely on hooks, filters, or template parts.

The PTU plugin works by utilizing core WordPress functionality. Custom post types and taxonomies are registered as post types themselves, and the settings for these custom types are stored in a custom metabox. When the page loads, the PTU plugin queries the custom post types and taxonomies, registers them, and stores them in a class variable for quick retrieval.

- Advertisement -

To retrieve a list of the custom post types and taxonomies, you can use the functions PTUPostTypes::get_registered_items() and PTUTaxonomies::get_registered_items(). These functions return arrays of the registered post types and taxonomies, respectively.

To retrieve the value of a specific setting for a post type or taxonomy, you can use the core WordPress function get_post_meta(). The settings are stored as custom fields, and the function allows you to retrieve the value of a specific setting by specifying the post type or taxonomy name and the option ID.

- Advertisement -

Adding custom options to the PTU plugin is a straightforward process. You can create new tabs in the default metabox by hooking into the ptu/posttypes/meta_box_tabs and ptu/taxonomies/meta_box_tab filters. Within these tabs, you can add custom options such as checkboxes, text fields, select dropdowns, and more.

The PTU plugin also supports conditional (show/hide) fields, which allow you to control the visibility of tabs and options based on specific conditions. For example, you can add a tab that only displays if a certain setting is enabled, or you can make an option visible only if another option is selected.

In conclusion, the PTU plugin is a valuable tool for WordPress site owners who want to add custom post types and taxonomies to their website. By adding custom options to the plugin, you can provide users with greater control over the design and functionality of their content. Whether you’re a theme developer or a non-developer, the PTU plugin makes it easy to create advanced and personalized websites without the need for extensive coding knowledge.

- Advertisement -

Stay in Touch

spot_img

Related Articles