This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Disable a search field from a specific page

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Disable a search field from a specific page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #19156
    Yaniv Cohenbenny
    Participant

    Hi
    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

    #19166
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi 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.

    #19184
    Yaniv Cohenbenny
    Participant

    Thank you Ernest

    It is working, I am happy (-:, Amazing and very flexible plugin

    Thank Benny

    #19185
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

    #19192
    Yaniv Cohenbenny
    Participant

    You cannot access this content.

    #19193
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Disable a search field from a specific page’ is closed to new replies.