-
Author
Tagged: ajax search pro, top menu
-
May 28, 2017 at 05:41 #162839
cd690767
ParticipantHi,
You told me earlier how to add a search to the top menu with the code below:
function kleo_search_menu_item( $items, $args ) {
if ( sq_option( ‘ajax_search’, 1 ) == ‘logged_in’ && ! is_user_logged_in() ) {
return $items;}
$location = sq_option( ‘menu_search_location’, ‘primary’ );
if ( $args->theme_location == ‘top’ ) {
$form = kleo_get_search_menu_item();
$items .= ” . $form . ”; }
return $items;}}
Now I’ve installed Ajax Search Pro and for some reason the search in the top menu isn’t executing the search from ajax search pro search, it is still executing the KLEO search. Can you tell me where I need to add the ASP shortcode (echo do_shortcode(‘[wpdreams_ajaxsearchpro id=1]’);) to the code shown above?
Thanks
Cathy
May 29, 2017 at 17:28 #162898Laura
ModeratorHello, will assign the ticket to a higher support level who can help and advise you in your query.
Thanks! ?Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionMay 31, 2017 at 19:10 #163128Radu
ModeratorHi,
You can try to edit that function like that, give a try
COPY CODEfunction kleo_search_menu_item( $items, $args ) { if ( sq_option( 'ajax_search', 1 ) == 'logged_in' && ! is_user_logged_in() ) { return $items; } $location = sq_option( 'menu_search_location’, 'primary' ); if ( $args->theme_location == 'top' ) { $form = echo do_shortcode('[wpdreams_ajaxsearchpro id=1]) ); $items .= " . $form . "; } return $items;} }Let me know
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 1, 2017 at 00:05 #163171cd690767
ParticipantHi Radu,
Thanks for the help, but unfortunately it doesn’t work- I get the error shown below:
Parse error: syntax error, unexpected ‘primary’ (T_STRING) in /home/XXXXX/public_html/wp-content/themes/kleo-child/functions.php on line 101
line 101 is:
$location = sq_option( ‘menu_search_location’, ‘primary’ );I changed “primary” to “top” but got the same error.
Regards,
CathyJune 5, 2017 at 15:12 #163401Radu
ModeratorHi,
Try again using this code instead of previous one.
COPY CODEif ( ! function_exists( 'kleo_search_menu_item' ) ) { /** * Add search to menu * * @param string $items * @param object $args * * @return string */ function kleo_search_menu_item( $items, $args ) { if ( sq_option( 'ajax_search', 1 ) == 'logged_in' && ! is_user_logged_in() ) { return $items; } $location = sq_option( 'menu_search_location', 'primary' ); if ( $args->theme_location == $location ) { $form = echo do_shortcode('[wpdreams_ajaxsearchpro id=1]') ); $items .= '<li id="nav-menu-item-search" class="menu-item kleo-search-nav">' . $form . '</li>'; } return $items; } }Let me know
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 6, 2017 at 00:43 #163479cd690767
ParticipantHi Radu,
Thanks for the continued help but this snippet doesn’t work either. I get this error:
Parse error: syntax error, unexpected ‘;’ in /home/XXXXX/public_html/wp-content/themes/kleo-child/functions.php on line 97Line 97 is:
if ( sq_option( ‘ajax_search’, 1 ) == ‘logged_in’ && ! is_user_logged_in() ) {I tried removing each ; but that didn’t work. Removing both ; gave an error for the !.
If this won’t work let me know and I’ll take the search out of the top menu.
Regards,
CathyJune 7, 2017 at 18:45 #163657Radu
ModeratorHi,
Replace with this one : https://pastebin.com/raw/RPANuCA6
Let me know
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 17, 2017 at 04:05 #164495cd690767
ParticipantHi Radu,
I thought I replied several days ago; sorry for the delay! This snippet also doesn’t work- it gives the following error:
Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in /home/XXXXX/public_html/wp-content/themes/kleo-child/functions.php on line 103line 103 is:
$form = echo do_shortcode(‘[wpdreams_ajaxsearchpro id=1])’);If I remove “echo” then there is no error, but then if I enter a search term in the search form in the top menu, the search form disappears from the menu after I hit enter.
Any other suggestions?
Thanks
CathyJune 20, 2017 at 15:42 #164728Radu
ModeratorI see,
Please create a page in that you will paste only this shortcode [wpdreams_ajaxsearchpro id=1]
to see exactly what is rendered or give me the admin credentials to take a closer look.
cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 20, 2017 at 23:10 #164789cd690767
ParticipantHi Radu,
Sorry this keeps causing problems; feel free to tell me you don’t want to worry about it anymore.
When I put the ASP shortcode in a page, I get the same output as in the ASP widget- the search results are styled according to settings of ASP and displayed beneath the search form. It all seems to work like it should.
With the kleo search in the top menu, when I type in a search term I also get ajax results displayed beneath the search form until I hit enter, at which point some results are displayed on a page (but they are not in the same format as they are in the ajax display).
Regards,
CathyJune 23, 2017 at 15:56 #165010Radu
ModeratorHi,
If those can be combined easy I can help you but I need to see it’s this can be made easy or not.
When I access your website it’s displayed coming soon page and i cannot see how the ASP shortcode.
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 23, 2017 at 23:33 #165060cd690767
ParticipantHi Radu,
My website isn’t launched yet – I’m using the Coming Soon plugin. Please keep it on while you’re logged into my site.
I have an admin account for support issues:
site: https://www.precisionmedicinecommunity.com/jointhecommunity
login: supportuser
password: 1234!@#$Mysiteisgr8
password for protected pages: pageThe page with the asp shortcode is: /test-for-asp-shortcode
I also have the shortcode in the sidebar all all pages but the home page.Thanks for the continued help with this issue,
Cathy
June 27, 2017 at 17:12 #165391Radu
ModeratorI saw how it behaves… but I don’t know if this can be easily integrated, please provide and FTP credentials to see it’s an easy way to do this.
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 28, 2017 at 02:59 #165486cd690767
ParticipantHi Radu,
I really appreciate the help – let me know if this is too much trouble to continue, I understand if it is.
Here’s FTP login info:
wpmatic@precisionmedicinecommunity.com
http://ftp.precisionmedicinecommunity.com
/home/preci832/public_html
password: 1234!@#$Regards,
CathyJuly 4, 2017 at 16:26 #166247Radu
ModeratorHi,
FTP works but the admin credentials are incorrect

Let me know
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 11, 2017 at 00:32 #166982cd690767
ParticipantHi Radu,
Sorry for the delayed reply- I was out of town. Here is the login info:
login: https://www.precisionmedicinecommunity.com/jointhecommunity
username: supportuser
password: 1234!@#$Mysiteisgr8Thanks for the help!
CathyJuly 12, 2017 at 17:33 #167172Radu
ModeratorHi,
Fixed! Check the search icon from the menu
I’ve replaced code with this one in child theme functions.php file
COPY CODEif ( ! function_exists( 'kleo_get_search_menu_item' ) ) { function kleo_get_search_menu_item() { $context = sq_option( 'search_context', '' ); if ( is_array( $context ) ) { $context = implode( ',', $context ); } //Defaults $action = home_url( '/' ); $hidden = ''; $input_name = 's'; if ( function_exists( 'bp_is_active' ) && $context == 'members' ) { //Buddypress members form link $action = bp_get_members_directory_permalink(); } elseif ( function_exists( 'bp_is_active' ) && bp_is_active( 'groups' ) && $context == 'groups' ) { //Buddypress group directory link $action = bp_get_groups_directory_permalink(); } elseif ( class_exists( 'bbPress' ) && $context == 'forum' ) { $action = bbp_get_search_url(); $input_name = 'bbp_search'; } elseif ( $context == 'product' ) { $hidden .= '<input type="hidden" name="post_type" value="product">'; $action = home_url( '/' ) . '?post_type=product'; } ob_start(); ?> <a class="search-trigger" href="#"><i class="icon icon-search"></i></a> <div class="kleo-search-wrap searchHidden" id="ajax_search_container"> <?php echo do_shortcode('[wpdreams_ajaxsearchpro id=1]'); ?> <div class="kleo_ajax_results"></div> </div> <?php $form = ob_get_clean(); return $form; } }Also, I've added this CSS in quick css area to make a little space between input search form and the container edges.
COPY CODE#header div#ajax_search_container { padding: 10px 10px; }
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Ticket solutionJuly 13, 2017 at 07:04 #167252cd690767
ParticipantHi Radu,
Thanks so much for your help with this! The search works great and looks great, but I originally wanted to have the search form in the TOP menu, not in the main menu. Is this not going to work with Ajax Search Pro?
Regards,
CathyJuly 14, 2017 at 17:27 #167425Radu
ModeratorAdd this function
COPY CODEif ( ! function_exists( 'kleo_search_menu_item' ) ) { /** * Add search to menu * * @param string $items * @param object $args * * @return string */ function kleo_search_menu_item( $items, $args ) { if ( sq_option( 'ajax_search', 1 ) == 'logged_in' && ! is_user_logged_in() ) { return $items; } //$location = sq_option( 'menu_search_location', 'primary' ); if ( $args->theme_location == 'top' ) { $form = kleo_get_search_menu_item(); $items .= '<li id="nav-menu-item-search" class="menu-item kleo-search-nav">' . $form . '</li>'; } return $items; } }The function needs to be pasted in wp-content/themes/kleo-child/functions.php
NOTE : Child theme needs to be installed and activated.
Tested on my local install the seatch item will go to topbar.
Please leave us a review on themeforest about your experience and give us 5* if you think the support it’s high quality.
Have a nice day
Regards
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 17, 2017 at 23:53 #167746cd690767
ParticipantHi Radu,
That worked! The search icon is now in the top menu. However, the search box opens up in the middle of the menu even though the search icon is on the right edge of the menu. You mentioned before that there is no solution for this to move it over, but if by some chance you ever find one let me know.
Thanks very much for all of your help!!
Cathy
July 18, 2017 at 18:36 #167837Radu
ModeratorYou’re welcome
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘Bugs & Issues’ is closed to new topics and replies.