Skip Navigation

[Résolu] How to get Types CPTs recognised by Visual Composer

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
How to use Custom Posts created with types on Visual Composer?

Solution (include the steps to follow here):
Use this in your functions.php:

add_action( 'init', 'wpcf_init_custom_types_taxonomies', 1); 
This support ticket is created Il y a 8 années et 5 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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

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

Last updated by timB Il y a 8 années et 5 mois.

Assisted by: Beda.

Auteur
Publications
#346015
VC-Types.png

I am trying to work on a client site which has Visual Composer (VC) installed.
VC has a GUI for installing shortcodes which create grids of content from posts, pages and (so it claims) custom post types.

However, the custom post types I have created using Types are not recognised by VC and therefore don't appear available in the drop-down box for selecting the data source. There are two Types-generated CPTs only - wp-types-groups and wp-types-user-groups, plus several CPTs which came with the WP theme (see the attached screenshot). But no sign of the CPTs I created in types.

I visited this URL:
https://toolset.com/forums/topic/populating-data-with-visual-composer/
Which is to do with compatibility of VC within Toolset, however that isn't a problem for me.

I also visited:
https://wordpress.org/support/topic/custom-post-type-and-visual-composer-grid-block
Which has a solution for enabling custom fields built using the Custom Post Type UI plugin. It proposes a change in the functions.php file to change the priorities of the CPTs so they are recognised by VC.
- is there a similar fix to change the priorities of Types custom fields which I can use in my functions.php? -or does someone know another work around to get this working?

I have submitted tickets to VC help desk about this matter too.

Thank you
Tim

#346316

Thank you for contacting Toolset Support, I'd be delighted to assist!

Have you tried making sure that Visual Composer is enabled for your CPTs? See: hidden link

Do they show up? Are they marked? Are you sure the user you are attempting to use VC with has the correct permissions? It would be nice if VC would use this settings page to register CPTs for it's integrated modules, we shall see.

I look forward to your reply!

#346350
vc-settings.png

Hi Ross

Thanks for your response... I have tried making sure VC is enabled for my CPTs, yes. (see attached). Post types created in Types do show up in this list, and are checkable in VC settings, and the user I am logged in with does have the right permissions (see attached).

However, the CPT's created in Types don't show up in VC's element data sources (as shown in previous post's attachment.

This is how VC have responded to my ticket with them:
-----------------------
"For a CPT to be displayed in the grid, it needs a a higher priority. If you are using custom post UI plugin then they have this code on line 107 of custom-post-type-ui.php:

add_action( 'init', 'cptui_create_custom_post_types', 10 );

You should change it to:

add_action( 'init', 'cptui_create_custom_post_types', 1);"

------------------------

This refers to a solution found for another CPT plugin at this post (as per my last ticket):
https://wordpress.org/support/topic/custom-post-type-and-visual-composer-grid-block

I could add a line like this (or more) to my child theme's functions.php but can you tell me what the code should be?

Thank you
Tim

#347294

Hi again Ross...

Did you see my last message in this thread?
I notice only I am being notified of updates and not you. Should I add a new ticket, or are you still working on this?

Thank you
Tim

#347642

Since Ross currently has a few days off, I will replace him here in the forum.
I hope this is OK for you.

I would suggest you try this 2 options (in functions.php) and see which one works:

1.

add_action( 'init', 'wpcf_init_custom_types_taxonomies', 1); 

2.

add_filter('wpcf_init_custom_types_taxonomies', 'my_priority_wpcf_init_custom_types_taxonomies');
function my_priority_wpcf_init_custom_types_taxonomies($p)
{
     return 1;
}

Please let me know if the above solution works for you, I look forward to your reply!

Thank you for your patience.

#347740

Thanks for that Beda

The first of your code samples worked on my site.
I can now see the CPTs created in Types and access them using Visual Composer.

Many thanks
Tim

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.