Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Disable result link (click action)
- This topic has 8 replies, 2 voices, and was last updated 1 year, 4 months ago by
sparkcreative.
-
AuthorPosts
-
January 10, 2025 at 11:31 pm #52454
sparkcreative
ParticipantHello. I’d like to turn off the click action to the posts and search results in AJSP. I have turned off ” Make the whole result area clickable?”, and the items are still clickable for me. I’m using the isotopic layout.
January 11, 2025 at 4:45 pm #52458Ernest Marcinko
KeymasterHi!
The easiest and simplest way to do it is by using this custom CSS:
.asp_r .item { pointer-events: none !important; }This will prevent any clicks on the browser level, without making any modifications on the plugin code.
January 12, 2025 at 5:13 pm #52461sparkcreative
ParticipantI came across that solution in another thread. I’d like some of the results to be clickable, I have modified the results HTML to have a button. Some will not have a button, and should not be clickable.
What’s the harder way of accomplishing this?
January 13, 2025 at 11:30 am #52465Ernest Marcinko
KeymasterOh, okay!
In that case it would the the best to simply unset the results links via a custom code:
add_filter( 'asp_results', 'asp_custom_link_results', 10, 1 ); function asp_custom_link_results( $results ) { foreach ($results as $k=>&$r) { $r->link = ''; } return $results; }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.
January 13, 2025 at 8:56 pm #52470sparkcreative
ParticipantYou cannot access this content.
January 14, 2025 at 5:59 pm #52489Ernest Marcinko
KeymasterOkay, this seems to be very close.
The Bio link href is however missing, it should be something like this:
<a href="<?php echo get_permalink($r->id); ?>" <?php echo ($s_options['results_click_blank']) ? " target='_blank'" : ""; ?>>View Bio</a>I can’t see any other issues there.
January 14, 2025 at 7:44 pm #52490sparkcreative
ParticipantIt’s very close. The URLs look correct on hover now, but they still have the click event over the result that prevents the links from working.
function(t) {
if (!i.dragging) {
let s = e(this).find(“.asp_content a.asp_res_url”),
l = s.attr(“href”);
l !== “” && (t.preventDefault(), t.which === 2 || s.attr(“target”) === “_blank” ? c.openInNewTab(l) : location.href = l)
}
}—-
I updated the link with ‘get_permalink($r->id);’, and still have the first function code added to the theme.
January 15, 2025 at 10:04 am #52496Ernest Marcinko
KeymasterOkay. Let’s try to force all click actions off via this custom code:
add_action( 'wp_footer', function () { ?> <script> document.querySelectorAll(".asp_main_container").forEach((el) => { el.addEventListener("asp_results_show", (event) => { console.log('hey'); setTimeout(()=>DoMini(".asp_r .item").off(), 10); }); }); </script> <?php }, 9999 );January 15, 2025 at 10:52 pm #52504sparkcreative
ParticipantThat handles it perfectly, thank you!
-
AuthorPosts
- You must be logged in to reply to this topic.