Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1216905

    I have this in child functions.php, I modified form action of default search.

    add_filter('avf_frontend_search_form_param', my_frontend_search_form_param, 10, 1 );
    function my_frontend_search_form_param( array $params )
    {
    	global $wp;
    	$params['form_action'] = home_url( $wp->request . '/' );
    
    	return $params;
    }

    I have another function for another search:

    add_action( 'ava_after_main_title', 'add_my_custom_code' );
    function add_my_custom_code() {
      if ( is_front_page() || is_archive() || is_tag() ) {
        echo '<div id="av_section_112" class="avia-section main_color avia-section-default avia-no-border-styling  avia-bg-style-scroll  avia-builder-el-0  el_before_av_button  avia-builder-el-first   container_wrap fullsize" style=" "><div class="container">
    <div class="flex_column av_one_half  flex_column_div av-zero-column-padding first  avia-builder-el-1  el_before_av_one_half  avia-builder-el-first  " style="border-radius:0px; ">';
    
        echo do_shortcode("[avia_sc_search placeholder='Search...' label_text='SEARCH' icon_display='input' icon='ue803' font='entypo-fontello' post_types='' post_types_custom='post' numberposts='5' display='classic' ajax_location='form_absolute' ajax_container='#my_container' results_hide_titles='aviaTBresults_hide_titles' results_hide_meta='aviaTBresults_hide_meta' custom_input_size='16' custom_button_size='' custom_height='44' radius='10px' radius_sync='true' border_width='' results_padding='0px' results_padding_sync='true' results_margin='0px' results_margin_sync='true' border_color='' custom_border_color='' input_color='' custom_input_color='' input_bg='' custom_input_bg='' button_color='' custom_button_color='' button_bg='' custom_button_bg='' results_color='' custom_results_color='' results_bg='' custom_results_bg='' id='' custom_class='' av_uid='av-kajngbb8' admin_preview_bg='']");
    
        echo '</div><div class="flex_column av_one_half  flex_column_div av-zero-column-padding   avia-builder-el-3  el_after_av_one_half  avia-builder-el-last  " style="border-radius:0px; "></div></div></div>';
      }
    }

    How can I set $params[‘form_action’] = home_url( $wp->request . ‘/’ ); for second search (shortcode search) ?

    I want the two search inputs to get the same result.

    Also another question,
    $params[‘form_action’] = home_url( $wp->request . ‘/’ ); is set when click search. But, how can I modify this for ajax result, before search is clicked?

    #1218737

    Any response?

    #1219214

    Hi,

    Sorry for the late reply!

    Please refer to this post – https://kriesi.at/documentation/enfold/intro-to-layout-builder/#add-elements-to-alb and create a child theme and a “shortcodes” folder inside your child theme.
    Then go to /wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/search/search.php file and copy it inside /shortcodes/ folder inside your child theme.
    Open the file and find following line and adjust it as needed

    
    $form_action = home_url( '/' );
    

    This is for Search element.

    Your following code changes form action of ajax search as well as default search

    add_filter('avf_frontend_search_form_param', my_frontend_search_form_param, 10, 1 );
    function my_frontend_search_form_param( array $params )
    {
    	global $wp;
    	$params['form_action'] = home_url( $wp->request . '/' );
    
    	return $params;
    }

    Best regards,
    Yigit

    #1219314

    Thank you very much Yigit!
    The first is good solution for mu case, but I find the other solution. I make custom form inside function.

    add_action( 'ava_after_main_title', 'add_my_custom_code' );
    function add_my_custom_code() {
      if ( is_front_page() || is_archive() || is_tag() ) {
        echo '<div id="av_section_112" class="avia-section main_color avia-section-default avia-no-border-styling  avia-bg-style-scroll  avia-builder-el-0  el_before_av_button  avia-builder-el-first   container_wrap fullsize" style=" "><div class="container">
    <div class="flex_column av_one_half  flex_column_div av-zero-column-padding first  avia-builder-el-1  el_before_av_one_half  avia-builder-el-first  " style="border-radius:0px; ">';
    
        global $wp;
        echo '<div class="avia_search_element  ">';
        echo '<form action="'. home_url( $wp->request . '/' ) .'" id="searchform_element" method="get" class="av_disable_ajax_search" _lpchecked="1">';
    ?>
        <div class="av_searchform_wrapper" style="border-radius:10px; "><input type="text" value="<?php if(!empty($_GET['s'])) echo get_search_query(); ?>" id="s" name="s" placeholder="Search..." style="border-radius:10px; line-height:44px; height:44px; font-size:16px; " class=" av-input-hasicon"><span class="av-search-icon avia-font-entypo-fontello" style="font-size:16px; "></span><div class="av_searchsubmit_wrapper" style="border-radius:10px; "><input type="submit" value="SEARCH" id="searchsubmit" class="button" style="border-radius:10px; "></div></div>
    
    <?php
        echo '</form></div>';
    
        echo '</div><div class="flex_column av_one_half  flex_column_div av-zero-column-padding   avia-builder-el-3  el_after_av_one_half  avia-builder-el-last  " style="border-radius:0px; "></div></div></div>';
      }
    }

    The code doesn’t change form action of ajax search as default search. I disabled Ajax, it’s not necessary in my web.
    It’s not working when I clicked to list posts of some category (with archive.php). I type something into the main search and with ajax show 6 posts for example. When hit enter show only 2 in search results. I also use relevanssi search plugin, maybe that’s the problem.

    Thanks!

    #1221784

    Hi,

    Is it working properly when the relevanssi plugin is disabled? Did you disable the ajax search? Please note that the filter avf_frontend_search_form_param will only affect the default search field from the theme.

    What do you mean exactly by “default search”?

    Best regards,
    Ismael

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.