skip to Main Content
Fix: Visual Composer Not Loading After WordPress Update

Fix: Visual Composer Not Loading After WordPress Update

A common problem that I have seen with clients websites is that after a updating WordPress to 4.5 of higher visual composer stops loading.

visual-composer-not-loading

 

Debugging the issue via your favorite browsers Inspect Element feature will likely show the following JavaScript error “Uncaught TypeError: $template.get is not a function”

debugging-visual-composer

 

Fortunately thanks to Amritosh on the WordPress forums there is a fix for this. First you will need edit the following file in your preferred text editor: /wp-content/plugins/js_composer/assets/js/backend/composer-view.js

 

Location the function

html2element: function ( html ) {
			var attributes = {},
				$template;
			if ( _.isString( html ) ) {
				this.template = _.template( html );
				$template = $( this.template( this.model.toJSON(), vc.templateOptions.default ).trim() );
			} else {
				this.template = html;
				$template = html;
			}
			_.each( $template.get( 0 ).attributes, function ( attr ) {
				attributes[ attr.name ] = attr.value;
			} );
			this.$el.attr( attributes ).html( $template.html() );
			this.setContent();
			this.renderContent();

		},

And replace it with the following:

html2element: function(html) {
            var $template, attributes = {},
                template = html;
            $template = $(template(this.model.toJSON()).trim()), _.each($template.get(0).attributes, function(attr) {
                attributes[attr.name] = attr.value
            }), this.$el.attr(attributes).html($template.html()), this.setContent(), this.renderContent()
        },

Presto! Your Visual Composer should now be loading again.

PS: Remember to clear the cache if you are using any cache plugins
WP Bakery’s Visual Composer is a favorite among both developers and clients as it’s code is fairly clean compared to past drag and drop editors but sometimes bugs do arise. Subscribe to our newsletter to get updates on your favorite WordPress plugin fixes & updates.

0/5 (0 Reviews)