Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Disable a search field from a specific page
- This topic has 5 replies, 2 voices, and was last updated 7 years, 8 months ago by
Ernest Marcinko.
-
AuthorPosts
-
September 12, 2018 at 5:37 pm #19156
benny
ParticipantHi
In fact I do not have a plugin problem, I need a tip that I could not find in Help, I set up and Create a new search instance [wd_asp id=1] in me ecommerce site, This shortcode Is displayed automatically (OR NOT) all over the pages site: Woocommerce shop, product pages, home page and so…I set up and one more search instance [wd_asp id=2], If I past this shortcode in homepage for example, I will see both of them. I did not find a way to disable the first one from a specific page (Like homepage) to display only the second one.
I broke my head to find a solution, maybe I forgot about any definition setup, please have help to guide me on the subject
In fact I need to use the power of the plugin to place different search fields on different pages (not much) but that will be adjusted as much as possible to our customers
Thanks Benny
September 13, 2018 at 12:30 pm #19166Ernest Marcinko
KeymasterHi Benny,
If I understand correctly, you have 2 search instances:
– 1 is used to be displayed everywhere (via a shortcode or override etc..)
– 2 is only used on specific pages
You want to exclude the first one (1) from some of the pages, is that correct?It should be possible by using a custom code, to detect which page ID is currently displayed, then disable the shortcode on those pages. A modification to the core code is also required, as the shortcode output is not filtered.
Step 1 – Change the core code
1. Open up the wp-content\plugins\ajax-search-pro\includes\classes\shortcodes\class-asp-search.php file on your server
2. Scroll to line 216, which should be this:[php] return $out;[/php]
3. Change that line to this:
[php]return apply_filters(‘asp_shortcode_output’, $out, $id);[/php]
Step 2 – Custom code
Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
Change variables $disabled_pages, $disable_home and $search_id according to your needs.
September 14, 2018 at 9:28 am #19184benny
ParticipantThank you Ernest
It is working, I am happy (-:, Amazing and very flexible plugin
Thank Benny
September 14, 2018 at 10:42 am #19185Ernest Marcinko
KeymasterYou cannot access this content.
September 14, 2018 at 3:02 pm #19192benny
ParticipantYou cannot access this content.
September 14, 2018 at 3:21 pm #19193Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- The topic ‘Disable a search field from a specific page’ is closed to new replies.