Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Visual Composer: Post grid element and output HTML WordPress

  • SOLVED

Hi all!

Site theme uses Visual composer as a base for building pages and posts. Site blog page uses some "Post grid" elements to display recent posts and some categories posts (5 instances in total). "Grid element template" for them is 2 custom grids based on "Basic grid: Default".

All this blocks are visible on the actual page but cut from page source code and not visible by SEs.

It's caused by this script:
wp-content/plugins/js_composer/assets/js/dist/vc_grid.min.js
that loads content of this blocks in its own manner.

I've tried 2 solutions and both didn't work for me:
1) adding this to the functions.php:
function remove_vc_vcgrid(){
wp_dequeue_script( 'vc_grid.min' );
wp_deregister_script( 'vc_grid.min' );
wp_dequeue_style( 'vc_grid.min' );
wp_deregister_style( 'vc_grid.min' );
}
add_action( 'wp_enqueue_scripts', 'remove_vc_vcgrid', 9999 );

2) removing all script content - blocks aren't loaded at all after this.

Please recommend how to solve this issue.

PS: I can PM site URL if needed.

PS2: I've used header method by TomsRiverWebDesign from here https://wordpress.org/ideas/topic/function-to-display-an-array-of-all-enqueued-scriptsstyles to get all handles - here it is:
https://www.pastiebin.com/59c6dc3a7dcb5

Thanks.

Answers (3)

2017-09-23

Cesar Contreras answers:

try removing the script with the handle name "vc_grid" not "vc_grid.min"


Alex B. comments:

It didn't help.

2017-09-25

Mohamed Ahmed answers:

// Post Grid Element
function dequeue_post_grid_element_scripts() {

wp_dequeue_script( 'vc_grid' );
wp_deregister_script( 'vc_grid' );
wp_dequeue_style( 'vc_grid' );
wp_deregister_style( 'vc_grid' );
}
add_action( 'wp_footer', 'dequeue_post_grid_element_scripts' );

2017-09-23

Kyle answers:

You shouldn't need the .min in there, but you may have to check the plugin for the unique "handle" name of the script to make sure it is right


Alex B. comments:

Kyle, I'm not a JS person or professional programmer. How to check unique "handle" name of the script? Thanks.


Kyle comments:

You have to look for the correlating function inside the plugin or theme. Somewhere it will have something similar to what you posted but it will look like...

function remove_vc_vcgrid(){
wp_enqueue_script ( 'vc_grid_handle', get_template_directory_uri() . '/js/vc_grid.min.js' );
}
add_action( 'wp_enqueue_scripts', 'remove_vc_vcgrid', 9999 );

That first part in the parenthesis is what you'll want in your function


Alex B. comments:

Kyle, please see my PS2 in the question. Does it help in some way?