How to add shortcode to Header Call-To-Action
-
In Responsive Theme, to allow a shortcode in the text for the Responsive theme’s ‘Call to Action’ button in the Header… modify template-parts/featured-area.php:
// taken from around line 50 in the file, in the call-to-action <div> block... <div class="call-to-action"> <a>" class="blue button"> <?php if ( isset( $responsive_options['cta_text'] ) && $db && $emtpy_cta ) { // this is the only changed line, modified to allow short-code: echo do_shortcode($responsive_options['cta_text']); // allow sc // original code: // echo $responsive_options['cta_text']; } else _e( 'Call to Action', 'responsive' ); ?> </a> </div><!-- end of .call-to-action -->
This mod allowed me to make a dynamically updating button label that reads ’42 Years of Achievements’ with the 42 updating automatically each year. You might come up with other ideas for it.
Actually, if you are using the child theme, copy the template-parts folder from the parent theme and modify your code in the child.
Bob
- The topic ‘How to add shortcode to Header Call-To-Action’ is closed to new replies.