Skip Navigation

[Fermé] Add supports parameter to a CPT

This support ticket is created Il y a 1 an et 2 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 3 réponses, has 2 voix.

Last updated by Christopher Amirian Il y a 1 an et 2 mois.

Assisted by: Christopher Amirian.

Auteur
Publications
#2559119

Tell us what you are trying to do?
I'm using a theme which needs me to add some code in order to be able to use their customizer settings to control the appearance of content archives. The theme gives this message:
"Enable Content Types
Archive content typesCustom post types must support "mai-archive-settings" to be available here."

I asked the theme's support what that meant and he said this:

>When you register a CPT in code, there is a parameter called "supports" where you put in an array of items like, [ 'title', 'editor', 'excerpt', 'mai-archive-settings', 'mai-single-settings' ]. I'd like to think Types has a field for adding in any custom supports elements. If not, you'll need to use code to filter the registered post type args, though at that point you might as well use code to register it too.

I understand that I could make an archive in your plugin but I really want to use the theme's customizer options because they are extensive.

Is there any documentation that you are following?

I've tried following your documentation but it's over my head.

Is there a similar example that we can see? Not that I can think of.

What is the link to your site?

hidden link

I'm not sure what you can see that will help but there it is.

I'm guessing I need to be in Settings>Custom Code? Can you tell me exactly what I need to do to accomplish what the theme dev told me I need to do?

Thank you!

#2559237

Christopher Amirian
Supporter

Languages: Anglais (English )

Hi there,

Unfortunately, it is not possible to do that with Toolset, but WordPress has a custom function that you can change the parameters a post type.

Maybe it can help? I am not sure but worth the try:

add_filter('register_post_type_args', 'movies_to_films', 10, 2);
function movies_to_films($args, $post_type){

    if ($post_type == 'property'){
		var_dump($args['supports']);
    }

    return $args;
}

In the code above change 'property' with the slug of your post type. You can add the code to the theme functions.php or use this method:

https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

Now I just print the 'supports' parameter, what you would add to that is what the theme developer can help you with.

So you can share this with the theme developer.

If it is not working for you that way, then you will need to create the Post Type with another tool such as:

hidden link

Thanks.

#2561255

Thank you so much for your quick and helpful reply!

I just wanted to give you a progress update. I sent this along to my theme developer and have asked him for feedback. He's also a quick and helpful replier so I have a plan to try. I'm hoping to get a chance to try it soon and will let you both know how it works out. I'm excited that it is going to work, just a matter of how many different tries it takes! Thanks again!

#2561759

Christopher Amirian
Supporter

Languages: Anglais (English )

Thank you for the update 🙂

Le sujet ‘[Fermé] Add supports parameter to a CPT’ est fermé à de nouvelles réponses.