Empower your business today! - Call 1300 991 992

How to add an ID field to Visual Composer Row element

How to add an ID field to Visual Composer Row element
Share this post

There are times when adding an ID to a row can be very handy, particularly when building single page sites. Visual Composer doesn’t provide this functionality, so in order to make it happen we need to get dirty with some code. In this blog I show you how.

Interestingly, there is already an element_id field on the row element which, when set, is automatically output. All we need to do is add a parameter for it on the Visual Composer editor.

VC API Reference – vc_add_param() – https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524335

How to…

In your theme’s functions.php file, add the following code:

$attributes = array(
 'type' => 'textfield',
 'heading' => "HTML ID",
 'param_name' => 'element_id',
 'value' => '',
 'description' => __( "Assign an ID to the row", "discprofile" )
vc_add_param( 'vc_row', $attributes );

Now, create or edit a row in Visual Composer. You should see the additional field on the General tab.

Save the page and preview it in your browser. Checking the markup output you should see something similar to the code below:

<div id="updates" class="vc_row wpb_row vc_row-fluid bg-parallax-parent" style="opacity: 1; background-image: url(http://staging.axiomit.com.au/discprofile/none); background-attachment: scroll; background-size: cover; background-position: 50% 50%; background-repeat: no-repeat;">
	<div class="vc_span12 wpb_column column_container">
		<div class="wpb_wrapper">



Learn more about Office 365
Get in touch with Axiom IT and we will happily assist you with any queries relating to Office 365.



Subscribe to our newsletter for the latest news on the Cloud and Office 365 products.

Tas Gray

Tas Gray is one of Axiom IT's directors. He spends most of his time working with Office 365 and other cloud technologies. He holds an MCSA in Office 365 and helps clients get the most from their Office 365 subscriptions.