Missing post grid element on pages built with WPBakery
This article in applicable to a WordPress installation with WPBakery plugin. I came across this issue when the Post grid elements created using WPBakery plugin were missing on the pages.
Check the payload and response of requests to admin-ajax.php file in Chrome’s network tab related to pulling data to populate the post grids with. You might see the following:
- failed_to_get_id as one of the parameters in the payload
- {“status”:”Nothing found”} as a response
If your case is the same as mine then:
- You have just upgraded from PHP 7.2 to 7.3
- Your WPBaker plugin is somewhat out of date
In the code of WPBakery plugin search for the following portion of a regular expression: “:([\w-_]+)“
In PHP 7.3, for the above regular expression to work as expected so that the hyphen matches, the hyphen needs to be escaped: “:([\w\-_]+)“.
Replace the all the regular expressions like the above in the code of WPBakery or upgrade the plugin to the latest version, if you can.
The following files contain this regular expession:
- include/autoload/hook-vc-grid.php (don’t forget the getShortcodeRegexForId() function)
- include/classes/shortcodes/vc-basic-grid.php
Once you make these changes, the post grid should start working – just resave the posts.
One way to check if things are working or not is to look in the wp_postmeta database table. WPBakery populates the _vc_post_settings meta field with the settings for shortcodes used for various WPBakery elements. If things are working well you will find that the _vc_post_settings meta value has a long array of values.
