Add a shortcode to add_shortcode in functions.php

This drove me a little crazy one afternoon. I had to add a gravity forms shortcode to a new add_shortcode script in functions.php

To accomplish this, I added this to my code:

' . do_shortcode($content) . '

Here is how it looks in its working example. I work best by watching. Too many people just give the answer without providing the question:

function full_cta_link( $atts, $content = null ) {
return '<div class="row"><div class="col-lg-3"><h2>Title</h2><p>Content.</p></div>
<div class="col-lg-3">' . do_shortcode($content) . '</div></div>';
}
add_shortcode('full_cta_call', 'full_cta_link');

Implementation

On the WordPress.org side, I used this to implement the shortcode:

[full_cta_call]
[gravityf0rm id="4" title="false" description="false"]
[/full_cta_call]

Hope this saves you a bit of time.

Isaac Adams-Hands

Full Stack Developer, Digital Marketer, and InfoSec enthusiast. He received his Bachelor’s Degree from the University of Western Sydney and his Business Diploma from Georgian College before joining various marketing positions in search portals, e-commerce, higher education, and addiction recovery services.

Follow @ twitter

Related posts

Minimize WP HTML w/o a plugin

Here is the code (adding it to your WordPress’s functions.php file) to minimize your themes HTML code without a plugin. Add to Functions.php

How to add a header image in WP

Here is a quick example of how to add a background image to the header of your WordPress website pulling the Feature Image Featured Image Code: You could also use: