WordPress.org

Ready to get started?Download WordPress

Forums

Adding a second button with php code? (4 posts)

  1. dubzzdigital
    Member
    Posted 10 months ago #

    Hi all,

    I have the website Cottage Flair and I am wanting to add a second button next to the "Shop Now" one in the purple bar of the homepage. I have tried editing the php functions myself but can't for the life of me figure it out. If anyone could please help it would be much appreciated! Cheers!

    This is what I am looking at:

    /****************************************************************************************/

    if ( ! function_exists( 'attitude_home_slogan' ) ) :
    /**
    * Display Home Slogan.
    *
    * Function that enable/disable the home slogan1 and home slogan2.
    */
    function attitude_home_slogan() {
    global $attitude_theme_options_settings;
    $options = $attitude_theme_options_settings;

    $attitude_home_slogan = '';
    if( ( !$attitude_home_slogan = get_transient( 'attitude_home_slogan' ) ) && ( !empty( $options[ 'home_slogan1' ] ) || !empty( $options[ 'home_slogan2' ] ) ) ) {

    if ( "0" == $options[ 'disable_slogan' ] ) {
    $attitude_home_slogan .= '<section class="slogan-wrap clearfix"><div class="container"><div class="slogan">';
    if ( !empty( $options[ 'home_slogan1' ] ) ) {
    $attitude_home_slogan .= esc_html( $options[ 'home_slogan1' ] );
    }
    if ( !empty( $options[ 'home_slogan2' ] ) ) {
    $attitude_home_slogan .= '<span>'.esc_html( $options[ 'home_slogan2' ] ).'</span>';
    }
    $attitude_home_slogan .= '</div><!-- .slogan -->';
    if ( !empty( $options[ 'button_text' ] ) && !empty( $options[ 'redirect_button_link' ] ) ) {
    $attitude_home_slogan .= ''.esc_html( $options[ 'button_text' ] ).'<!-- .view-work -->';
    }
    $attitude_home_slogan .= '</div><!-- .container --></section> <!-- .slogan-wrap -->';
    }

    set_transient( 'attitude_home_slogan', $attitude_home_slogan, 86940 );
    }
    echo $attitude_home_slogan;
    }
    endif;

    /****************************************************************************************/

  2. bcworkz
    Member
    Posted 10 months ago #

    Try something like this:

    //existing code
    $attitude_home_slogan .= ''.esc_html( $options[ 'button_text' ] ).'<!-- .view-work -->'
    }
    //insert the following
    $attitude_home_slogan .= '<a class="view-work" href="http://cottageflair.co.nz/$page_slug/">$button_text</a><!-- .view-work -->';
    //existing code continues...
    $attitude_home_slogan .= '</div><!-- .container --></section> <!-- .slogan-wrap -->';

    Where you replace $page_slug and $button_text with the actual desired values.

  3. dubzzdigital
    Member
    Posted 10 months ago #

    Thank you so much! You are awesome! That worked a treat!

    The new button is now sitting really close to the original. Any thoughts on how to get space between them?

    Cheers is advance!

  4. dubzzdigital
    Member
    Posted 10 months ago #

    Nevermind! Figured it out in the css myself. :o)

Reply

You must log in to post.

About this Topic