Add Call To Action Widget In Any StudioPress Theme

This tutorial is based on this forum question:

How can i add a call to action like the Executive Pro Theme?

Here’s the Executive Pro themes call to action widget taken directly from the demo site:

Executive Theme call to action widget with button

And here’s what the code in this post generates:

call to action

And here’s the PHP & CSS code:

Code Installation – Beginners Guide

  1. Copy the PHP code from the view raw link in the Gist labelled functions.php and paste it at the end of your child themes functions.php file using a code editor like Notepad++
  2. Copy the CSS code from the Gist labelled style.css and paste it at the end of your style.css file before the start of the Media Queries section.

Notes

  • Media Queries not included however you can grab these directly from the Executive Pro themes style sheet and change the classes to match what the PHP generates above.
  • Tested on the Genesis Sample child theme.
  • If your theme includes a front-page.php or home.php file, you hard code the widget into that file and remove the hook. The PHP code which registers the widget needs to stay in your functions file.
  • You can change the width of the call to action to full width in some themes ( Tested on Genesis Sample Only ) simply by changing the genesis hook from genesis_before_content_sidebar_wrap to genesis_after_header.

Add Background Image To Widget

You could also add a background image to your widget. Here’s an example:

background image

And here’s the CSS code. Note the path, file name and extension in your child themes images folder must match whats in the CSS:

.call-to-action {
background-image: url('images/bg.png');
}

.call-to-action is the CSS class included in the PHP code which generates the widget as you can see in the Gist above.

Related Posts


Comments

16 responses to “Add Call To Action Widget In Any StudioPress Theme”

  1. How do you make it mobile responsive?

    1. Brad Dalton Avatar
      Brad Dalton

      You’ll get the solution here Chris http://wpsites.net/registration/

  2. Hi Brad,

    Many thanks for this tutorial.
    I’m using the Executive Pro theme and I’m trying to set up a call to action widget to use in the posts, which is exactly as the one already visible in the homepage.
    I’m a newbie and I’m not sure whether I did right, but I followed your tutorial and added the right code to functions.php and to style.css.

    Then, to make the widget appear in the middle of a post I tried to add this:

    Call to Action Banner
    Here’s a great place to write something specific that you want your visitors to read.
    Contact Us Today

    but the widget title gets too much space.
    Taking out the line:
    Call to Action Banner
    I get a correct size of the call to action, but obviously the title is missing.

    Is it right to add the above in the middle of the post?
    And if so, could you please help me to get the correct code?

    Thanks for your support

    1. Brad Dalton Avatar
      Brad Dalton

      Marco

      That’s what membership is for. http://wpsites.net/registration/

  3. Love this tutorial, and thank you! But, how would I implement this using Genesis Simple Hooks? Would I just paste the below code into the appropriate area? Thanks in advance.

      1. hey, your reply was really helpful. thanks

        1. Brad Dalton Avatar
          Brad Dalton

          Anytime Zak and thanks for your comments.

  4. Hey brad question, how can you add a bg picture to the call to action banner?

    1. Brad Dalton Avatar
      Brad Dalton

      [code]
      .call-to-action {
      background-image: url(‘images/bg.png’);
      }
      [/code]

  5. Kristie Hill Avatar
    Kristie Hill

    AWESOME! I have been on the hunt for a tutorial like this. Thanks again, Brad!

  6. Great i got it!!!! Thanks for your help!!! I was able to place the hooks in different places and tested the before_ and after_ hooks dint understand at first. Great tutorial is in my bookmarks now. 🙂

    1. i will like to put it on the bottom 🙂

  7. Hello great post i was able to add the call to action widget but it show on the top header
    i think i will like to put if just before the footer widgets. Great stuff though 🙂

    1. Brad Dalton Avatar
      Brad Dalton

      Simply change the hook to genesis_before_footer

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.