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

Disable result link (click action)

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Disable result link (click action)

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #52454
    sparkcreativesparkcreative
    Participant

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

    #52458
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    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.

    #52461
    sparkcreativesparkcreative
    Participant

    I 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?

    #52465
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Oh, 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.

    #52470
    sparkcreativesparkcreative
    Participant

    You cannot access this content.

    #52489
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Okay, 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.

    #52490
    sparkcreativesparkcreative
    Participant

    It’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.

    • This reply was modified 1 year, 4 months ago by sparkcreative.
    #52496
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Okay. 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
    );
    #52504
    sparkcreativesparkcreative
    Participant

    That handles it perfectly, thank you!

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.