Short-code visual composite grid do_action not working

I have a visual composer that is filled with a common theme. When I put the following short grid code on my page in the editor, it works correctly.

[vc_basic_grid post_type = "post_type" max_items = "10" item = "masonryGrid_SlideFromLeft" grid_id = "vc_gid: 1458178666639-80ebf3775500c87d35de078c3422fe96-10" taxonomies = "555"]

However, when I call the same code using do_action, it gives the following javascript error. I checked the output of html and the same using do_action, for example by putting a short code in an editor.

Error: Syntax error, unrecognized expression: {'status': 'Nothing found'} s

Any help is greatly appreciated.

+6
source share
3 answers

Well, you can't output content directly to your templates using VC shortcodes like this.

1. Problem:

For security, other than nonce, VC uses shortcode_id and shortcode_id to verify AJAX / response data.

shortcode_id automatically generated by VC, you cannot encode it.

For example, this is a short code that you see on the admin editor screen:

[vc_basic_grid post_type="post_type" max_items="10" item="masonryGrid_SlideFromLeft" grid_id="vc_gid:1458178666639-80ebf3775500c87d35de078c3422fe96-10" taxonomies="555"]

Let's say that the page id is 4269, this is the generated HTML code on the interface:

 <!-- vc_grid start --> <div class="vc_grid-container-wrapper vc_clearfix"> <div class="vc_grid-container vc_clearfix wpb_content_element vc_masonry_grid" data-initial-loading-animation="zoomIn" data-vc-grid-settings="{"page_id":4269,"style":"all-masonry","action":"vc_get_vc_grid_data","shortcode_id":"1458178666639-80ebf3775500c87d35de078c3422fe96-10","tag":"vc_masonry_grid"}" data-vc-request="http://example.com/wp-admin/admin-ajax.php" data-vc-post-id="4269" data-vc-public-nonce="0641473b09"> </div> </div> <!-- vc_grid end --> 

Now, if shortcode_id and shortcode_id do not match, {'status':'Nothing found - $shorcode_id'} will be thrown away and the content will not be displayed.

You can find out more inside the vc_grid.min.js file.

2. Solution:

  • Create a fake page with VC, then copy the generated HTML code into your template file.
  • Create a template directly using VC.
  • Use the Shorcode Mapper to create your own shorcode.
+5
source

You can also try with do_shortcode ('');

how

do_shortcode ('[vc_basic_grid post_type = "post_type" max_items = "10" item = "masonryGrid_SlideFromLeft" grid_id = "vc_gid: 1458178666639-80ebf3775500c87d35de078c3422fe96-10" taxonomies = ";

Regards,

0
source

First, you create a new page and add a grid message to it, then we get

_vc_post_settings

send a meta and try to create a new one then update the metadata now we can pass the VC Ajax security check in the following code "1513628284966-37b8c3ca-d8ec-1" is a VC generated guid you must change it to yours.

 $meta = get_post_meta(1365,'_vc_post_settings'); $settings = array(); #$settings['vc_grid_id'] = $meta[0]['vc_grid_id']; $key = random_int(1513628284966,9513628284966); $settings['vc_grid_id']['shortcodes'][''.$key.'-37b8c3ca-d8ec-1'] = $meta[0]['vc_grid_id']['shortcodes']['1513628284966-37b8c3ca-d8ec-1']; $settings['vc_grid_id']['shortcodes'][''.$key.'-37b8c3ca-d8ec-1']['atts']['custom_query'] = "tag=shop"; $settings['vc_grid_id']['shortcodes'][''.$key.'-37b8c3ca-d8ec-1']['atts']['grid_id'] = ''.$key.'-37b8c3ca-d8ec-1'; $n = add_post_meta(1365,'_vc_post_settings',$settings); return do_shortcode("[vc_basic_grid post_type=\"custom\" show_filter=\"yes\" filter_style=\"dropdown\" item=\"5959\" grid_id=\"vc_gid:".$key."-37b8c3ca-d8ec-1\" filter_source=\"post_tag\" custom_query='tag=".$tag."']"); 
0
source

All Articles