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
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!
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
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
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.
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