Last active
November 23, 2017 07:11
-
-
Save mwender/66c484a45da924d915b5 to your computer and use it in GitHub Desktop.
Add an HTML ID option to Visual Composer rows in the X Theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function x_child_visual_composer_update_existing_shortcodes(){ | |
if ( function_exists( 'vc_add_param' ) ) { | |
vc_add_param( 'vc_row', array( | |
'type' => 'textfield', | |
'heading' => "HTML ID", | |
'param_name' => 'element_id', | |
'value' => '', | |
'description' => __( "Assign an ID to the row", "discprofile" ), | |
) ); | |
// Update 'vc_row' to include custom vc_row template and remap shortcode | |
$new_map = vc_map_update( 'vc_row', array( 'html_template' => locate_template( 'vc_templates/vc_row.php' ) ) ); | |
// Remove default vc_row | |
vc_remove_element( 'vc_row' ); | |
// Remap shortcode with custom template | |
vc_map( $new_map['vc_row'] ); | |
} | |
} | |
add_action( 'wp_loaded', 'x_child_visual_composer_update_existing_shortcodes' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mwender
I'm getting the following error when trying to use this function:
Fatal error: Wrong vc_map object. Base attribute is required
Do you have any ideas?