This topic has 7 replies, 2 voices, and was last updated 11 years by SQadmin.

  • Author
  • #659
     ZeRoE
    Participant

    Hi there,

    Is there an easy way to change the homepage search box to show Woocommerce Featured Products instead of “I am a…” “looking for a…”?

    Or if its not easy, how would it be done?

    Thanks

    #666
     SQadmin
    Keymaster

    Hi,
    You can change the function that renders the search form by adding this in sweetdate-child/functions.php

    COPY CODE
    
    function render_user_search() 
    {
        if (is_page_template('page-templates/front-page.php') AND sq_option('home_search',1) == 1)
            get_template_part('page-parts/home-search-form');
    }
    

    Try changing get_template_part(‘page-parts/home-search-form’); with what you want to show. It you want to display a shortcode you can do this:

    COPY CODE
    
    echo do_shortcode('[my_shortcode]');
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #757
     ZeRoE
    Participant

    Hey,

    Sorry I’m not very good with PHP, I pasted the above code into functions using Dreamweaver and it’s showing a syntax error on the “get_template_part” line of text. 🙁

    #762
     SQadmin
    Keymaster

    If you added it in sweetdate-child/functions.php it should work
    Anyway that was an example how to replace the form. Another one is to modify the way you like the form template:
    page-parts/home-search-form.php

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #982
     ZeRoE
    Participant

    Apologies for the delay.

    I added the above code to functions, I now get “Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in /wp-content/themes/sweetdate-child/functions.php on line 50”

    #998
     SQadmin
    Keymaster

    Hi,
    I don’t know what your code looks like. Please give more details on your problems.
    You should end up having:

    COPY CODE
    
    function render_user_search()
    {
        if (is_page_template('page-templates/front-page.php') AND sq_option('home_search',1) == 1)
            echo do_shortcode('[my_shortcode]');
    }
    

    Like I said, this is an example and you need to put an actual shortcode there.
    Regards

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #1024
     ZeRoE
    Participant

    Hey sqadmin,

    That works perfect, thanks!

    (Hopefully) Last question – Is there any way of merging it with the original style of the original search box?

    EDIT: Not last question apparently. When I try other shortcodes within the code, they align to the right of the page?

    #1046
     SQadmin
    Keymaster

    Hi,
    You need to do it from css to match the our form style.
    To keep the same width of as the original form you could wrap the shortcode like this:

    COPY CODE
    
    function render_user_search()
    {
        if (is_page_template('page-templates/front-page.php') AND sq_option('home_search',1) == 1)
    {
        echo '<div class="twelve columns">
          <div class="row">
              <div class="five columns">';
            echo do_shortcode('[my_shortcode]');
    echo '</div>
          </div><!--end row-->
        </div><!--end twelve-->';
    }
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?