I use the latest version of wordpress under php7, I use a theme that uses itself the plugin WPBakery Page Builder (based on visual composer).

I create a post that contains this:

[vc_row el_id="bloc-doc-a-telecharger"]
        [vc_basic_grid post_type="post" max_items="-1" style="pagination" items_per_page="4" element_width="3" arrows_design="vc_arrow-icon-arrow_09_left" arrows_position="outside" arrows_color="white" paging_color="white" item="1234" taxonomies="123"]

Shortcode so. Most of the time I can copy this kind of code and integrate it in php with do_shortcode('[my_short_code']) but it does not work here, it shows me the message "nothing_found". This is the style="pagination" that causes the error.

I specify that I try to integrate it in the file category.php and that if I integrate exactly the same code in page.php there it works.

  • You can add your VC code in a variable then using echo apply_filters( 'the_content', $your_variable); you can get shortcode data. – Bhupen Jul 4 '19 at 13:55
  • OK, just tried but it does the same... – Entretoize Jul 4 '19 at 14:11

I finally found the problem, in fact when you add pagination to visual composer post-grid shortcode, it will use ajax to load the things. But to communicate to the ajax php script it uses the post id. The problem is that the shortcode will have no post id if you create it live, or another post id if you use an external post as a model.

Then to make it works, I first create a page with the short code I want, then in my other page I get it contents like that :

$post = get_posts(array(    'name' => 'my-page-slug','post_type' => 'page'))[0];
print do_shortcode($post->post_content);

Notice the $post that is a global variable used by visual composer and that now have the correct post ID.


use shortcode inside single quotes as:

  • How is that related to the question? – fuxia Jul 4 '19 at 13:10
  • Yes you're true but that was just an example and I forgot the quotes typing... – Entretoize Jul 4 '19 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.