- This topic has 10 replies, 3 voices, and was last updated 2 years, 11 months ago by
Tom.
-
AuthorPosts
-
February 13, 2020 at 7:52 am #1164239
Chas
I’m using the Ajax Search Pro plugin to add a website search form to the menu of my GeneratePress themed site, but the search form appears to have a conflict with GeneratePress that doesn’t allow the form to get focus when the user clicks on it. The developer of the plugin determined that the cause is a conflict with a script that’s most likely generated by the theme, although he couldn’t pinpoint which script specifically. He said the developers of the theme would be able to spot it quickly. Can you help me diagnose where this conflict is coming from, and how I might resolve it?
To see the problem in action, I’ve given admins the URL of the site in a development environment. Notice that the same search form appears twice on the home page: once in the menu and once in the middle of the page. The one in the middle of the page works fine. The one in the menu doesn’t gain focus when the user clicks, so can’t work. (This is the core problem.)
Any help would be appreciated. Thanks.
February 13, 2020 at 4:12 pm #1164657Tom
Lead DeveloperLead DeveloperHi there,
I’m not seeing anything obvious.
Is it possible to hook the search into the navigation without adding it as a menu item? If there’s a function we can reference to output the search, I can help with the hook itself.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 14, 2020 at 8:46 am #1165512Chas
Yes, it is possible to hook the search form into the nav. Here’s a doc on the exact code snippet that does it: https://documentation.ajaxsearchpro.com/getting-started/placing-the-search-shortcode-in-theme-files
Looks pretty simple.
Which PHP file (and roughly where in the file) would I put the snippet to get the search bar to appear just to the right of the website title and the left of the menu? (I use the menu as header option.) Thanks for any info.
February 14, 2020 at 4:17 pm #1165757Tom
Lead DeveloperLead DeveloperYou could try this:
add_action( 'generate_inside_navigation', function() { echo '<div class="ajax-nav-search">'; echo do_shortcode( '[wpdreams_ajaxsearchpro id=1]' ); echo '</div>'; } );
Then you might need some CSS to tweak the positioning.
Let me know if it fixes the issue or not ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 17, 2020 at 10:28 am #1168331Chas
Sorry, I’m not a php guy. Which php file should this go in?
February 17, 2020 at 3:56 pm #1168592David
StaffCustomer SupportHi there,
this article explains:
https://docs.generatepress.com/article/adding-php/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 18, 2020 at 11:12 am #1169521Chas
Got it added, but it’s now located as the first thing on the page–before the “Site Identity” rather than in between Site Identity and primary navigation menu. How can I control the placement of the search bar?
February 18, 2020 at 3:40 pm #1169727Chas
Specifically, if I could place the search bar to the right of the site identity, rather than to the left of it, that would be perfect. Is there some other action I need to add to other than generate_inside_navigation that would place the search bar AFTER the site icon & name rather than BEFORE it? Thanks.
February 18, 2020 at 7:53 pm #1169850Tom
Lead DeveloperLead DeveloperGive this CSS a shot:
.ajax-nav-search { order: 1; margin-right: auto; } .navigation-branding { margin-right: 0; } #ajaxsearchpro1_1 { margin-top: 0; }
Adding CSS: https://docs.generatepress.com/article/adding-css/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 18, 2020 at 8:24 pm #1169862Chas
Worked perfectly, thanks!
February 18, 2020 at 8:29 pm #1169864Tom
Lead DeveloperLead DeveloperYou’re welcome ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.