Forum Replies Created
-
AuthorPosts
-
Ernest Marcinko
KeymasterHi,
Thank you very much for all the details!
The issue was, that the operator for the Region selector was incorrect, I fixed it for you: https://i.imgur.com/wJSNXlu.png
Now the filtering should work as expected.
Ernest Marcinko
KeymasterYou cannot access this content.
November 5, 2024 at 12:42 pm in reply to: Live Search results only displaying blogs, not pages, even though configured #51722Ernest Marcinko
KeymasterYou cannot access this content.
Ernest Marcinko
KeymasterYes, functions.php
Ernest Marcinko
KeymasterThat is exactly what the code I suggested should do:
add_filter( 'asp_shortcode_output', function( $output, $id ){ if ( $id != 1 ) { return $output; } if ( get_the_ID() == 13702 || get_the_ID() == 2428 ) { return ''; } return $output; }, 10, 2 );If it doesn’t work, then there is something wrong I can’t foresee, unfortunately I can’t test this code on my end as it needs the exact same setup as yours.
If you want, you can add temporary back-end and sFTP access, and I will debug this – it’s probably something very minor. I can’t guarantee anything (as custom code is beyond support), but I can try.
Ernest Marcinko
KeymasterWith your code variation it happens because the function first checks the page IDs, and when they match, it terminates empty (meaning that the search is not visible).
The search ID is only checked afterwards and at that point it does nothing whatsoever as on both condition the function terminates with the same output.-
This reply was modified 1 year, 7 months ago by
Ernest Marcinko.
Ernest Marcinko
KeymasterI don’t know then, the conditions look okay to me. The first condition terminates when the search ID is not 1, aka for all the other search instances in every case.
Then it goes further down to check the page IDs.If you want, I can check directly – but I need temporary back-end and sFTP access to make changes to the code. Can you please add those?
Ernest Marcinko
KeymasterThat very likely means that the search ID is incorrect in my code. Which search bar is the one in the header? I assumed “HomePage Search” from the screenshot, which had the ID=1.
Ernest Marcinko
KeymasterSure, we can try that!
Okay, so with this, the first search (ID=1) on pages 13702 and 2428 should be hidden. Should no affect any other search bars:
add_filter( 'asp_shortcode_output', function( $output, $id ){ if ( $id != 1 ) { return $output; } if ( get_the_ID() == 13702 || get_the_ID() == 2428 ) { return ''; } return $output; }, 10, 2 );Ernest Marcinko
KeymasterWell, this might be better to control via a plugin instead of a custom code.
Are you using some sort of a block in the header? I’m asking because there is this plugin, which may do exactly what you are looking for. Would that work for you?
Ernest Marcinko
KeymasterSure!
I assume you only want to apply this rule to the first search bar (id=1), then this modified version will do the trick:
add_filter( 'asp_shortcode_output', function( $output, $id ){ if ( $id != 1 ) { return $output; } if ( get_the_ID() !== 389 ) { return ''; } return $output; }, 10, 2 );Ernest Marcinko
KeymasterHi,
The images are not cached, so they are fetched every single time from WordPress core. I logged in and tried a few search phrases, but I’m getting the correct images in the live results list – as far as I could tell.
Can you link me a post where the image is incorrectly displayed in the search bar? I will check and debug that.
Ernest Marcinko
KeymasterHi Kimberly,
Surely! I assume you are using a widget/block in the header, but the header is globally displyed everywhere, so you probably can’t adjust that there. However it might still be possible via a custom code.
I have looked up your home page, it’s ID is 389, so I made a custom code snippet for you, which will check the current page ID, and if it’s not 389, then will intercept the search shortcode and will not print it.
Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
add_filter( 'asp_shortcode_output', function( $output ){ if ( get_the_ID() !== 389 ) { return ''; } return $output; } );November 4, 2024 at 11:34 am in reply to: Live Search results only displaying blogs, not pages, even though configured #51688Ernest Marcinko
KeymasterYou cannot access this content.
Ernest Marcinko
KeymasterYou cannot access this content.
-
This reply was modified 1 year, 7 months ago by
-
AuthorPosts