Move function from home.php to functions.php

Community Forums Forums Design Tips and Tricks Move function from home.php to functions.php

This topic is: not resolved

This topic contains 5 replies, has 2 voices, and was last updated by  braddalton 1 year, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #18590

    devinday
    Participant
    Post count: 7

    I am using the new executive theme located at turningpointehomes.com. The customer did not want to use the layout that came with the home.php layout. (I am using a static page for the homepage and not the home.php page that came with the theme)

    There is one section that the customer did want though. the Call the action section. (see screenshot)

    http://turningpointehomes.com/wp-content/uploads/2013/02/skitched-20130206-231630.jpg

    I am wondering how I can modify the call to action function that is in the home.php and create a new one for the functions.php page that allows me to insert the CTA widget as in the theme demo and have it show up on the current static homepage just above the footer.

    Hope this made sense. Been trying to do this myself for a couple hours, but havent made much progress.

    Thanks for looking.

    • This topic was modified 1 year, 5 months ago by  devinday.
    • This topic was modified 1 year, 5 months ago by  devinday.
    #18593

    braddalton
    Participant
    Post count: 8883

    Brian Gardner has written a very easy to follow tutorial which you can use for this: http://www.briangardner.com/welcome-text-widget/

    Change the code to something like this:
    [php]
    add_action( ‘genesis_before_footer’, ‘custom_welcome_text’ );
    function custom_welcome_text() {
    genesis_widget_area( ‘welcome-text’, array(
    ‘before’ => ‘<div class="welcome-text widget-area">’,
    ) );
    }
    [/php]

    You could add a conditional tag to this code if you want to display the widget content on the home page only or you can simply install the Widget Logic plugin and add is_home() to the widget logic field.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #19078

    devinday
    Participant
    Post count: 7

    Hi Brad,

    Thank you for your reply! OK, I have read your post and also reviewed brian’s post. Here is what I came up with.

    1. Registered New CTA widget area

    genesis_register_sidebar( array(
    'id' => 'welcome-cta',
    'name' => __( 'Welcome CTA', 'executive' ),
    'description' => __( 'This is the welcome cta widget.', 'executive' ),
    ) );

    2. Added the following function to functions.php


    /** Add the welcome CTA section */
    add_action( 'genesis_before_footer', 'custom_welcome_cta' );

    function custom_welcome_cta() {
    if (is_home() ) {
    genesis_widget_area( 'welcome-cta', array(
    'before' => '',
    ) );
    }
    }

    3. I referenced the div class in the above function to call the same CSS from the original theme call to action widget CSS

    This code is live now on the site, but my CTA widget is showing up on the home before the footer.

    Thoughts?

    #19079

    devinday
    Participant
    Post count: 7

    Hi Brad, Thank you for your reply! OK, I have read your post and also reviewed brian’s post. Here is what I came up with.

    1. Registered New CTA widget area

    genesis_register_sidebar( array( 'id' => 'welcome-cta', 'name' => __( 'Welcome CTA', 'executive' ), 'description' => __( 'This is the welcome cta widget.', 'executive' ), ) );

    2. Added the following function to functions.php

    /** Add the welcome CTA section */ add_action( 'genesis_before_footer', 'custom_welcome_cta' ); function custom_welcome_cta() { if (is_home() ) { genesis_widget_area( 'welcome-cta', array( 'before' => '
    ', ) ); } }

    3. I referenced the div class in the above function to call the same CSS from the original theme call to action widget CSS This code is live now on the site, but my CTA widget is showing up on the home before the footer.

    Thoughts?

    #19082

    devinday
    Participant
    Post count: 7

    Sorry the post was messed up. How did you properly add the code in your post? I put the code brackets around my, but the formatting went to crap.

    #19159

    braddalton
    Participant
    Post count: 8883

    Use square brackets in the text editor with the name of the code inside. [php][/php] [css][/css] [html][/html]

    Change the conditional tag to this if (is_page(007) and add the post. i.d for that page

    Change the hook to whereever you want the widget area:

    Example: add_action( ‘genesis_before_content’)

    If you could install the Genesis Simple Hooks plugin and paste in some text exactly where you want the widget content to ouput, i will write the code for you.

    Example code: http://pastebin.com/RZZAsxdQ


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.