Displaying a variable within a custom shortcode
-
I have an advanced custom field that i would like to output within a shortcode that i’ve created. My code looks like this:
// Adding shortcode for Title $cta_title = get_field('cta_title'); function cta_func( $atts, $content = null ) { return '<div class="black-box"> <h2 class="white">' . $cta_title . '</h2> </div> '; } add_shortcode( 'cta', 'cta_func' );
Have I declared the variable in the wrong place?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Displaying a variable within a custom shortcode’ is closed to new replies.