Tablepress table not showing preview

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Tablepress table not showing preview

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 3 years, 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #31097
    yeang.chng73
    yeang.chng73
    Participant

    Hi there,

    I am using Tablepress for tables, and i activated the Index engine to include that in Ajax Pro search results.

    However, when I search, the page “Test Table” shows up but no description preview of the content shows.

    You can try searching with the keyword “Claison”. The preview results correctly show for a different page with the same data(Phone-EMMC), but not done through the Tablepress plugin.

    If you go to the tablepress page, the text is white on a whiteish background so it’s hard to see. I need to fix the CSS but all the data is there.

    #31112
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    If I understand correctly, you want to display some of the tablepress table data within the live search preview?
    Well, the plugin by default gets only the unexecuted shortcode contents, but you can try changing that here. That does not mean, it will work properly or at all though – as many shortcodes, including the tablepress plugin are designed to work on a single page context.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #31116
    yeang.chng73
    yeang.chng73
    Participant

    Hi Ernest!

    Thank you for your quick support. Yes, exactly, I want to display some of the tablepress table data around the search hit term in the live search preview. The idea here is that the table is for phone numbers, and if the information needed shows up on the live preview, users will not even have to click through to the actual table page.

    I tried the option you ask, and did an index rebuild, and all it did was give the shortcode as the preview. See attached screenshot:

    Attachments:
    You must be logged in to view attached files.
    #31122
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    That means the shortcode is probably not registered at that time of execution. Maybe a solution with a custom code may work, but I cannot guarantee that either.

    Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter( 'asp_results', 'asp_force_execute_shortcodes', 10, 1 );
    function asp_force_execute_shortcodes( $results ) {
    	foreach ($results as $k=>&$r) {
    		if ( isset($r->post_type) ) {
    			$r->content = apply_filters('the_content', get_post_field('post_content', $r->id));
    		}
    	}
    
    	return $results;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #31125
    yeang.chng73
    yeang.chng73
    Participant

    Hi Ernest,

    Thanks for this code. However, it expanded the search for the page without tables, but for the page with Tablepress table it didn’t do anything:

    See screenshot attached.

    Attachments:
    You must be logged in to view attached files.
    #31128
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    In that case I’m afraid this is probably not possible. The tablepress shortcode is very likely not registered in that context of execution. Maybe one last chance via forceful shortcode execution with this code:

    add_filter( 'asp_results', 'asp_force_execute_shortcodes', 10, 1 );
    function asp_force_execute_shortcodes( $results ) {
    	foreach ($results as $k=>&$r) {
    		if ( isset($r->post_type) ) {
    			$r->content = do_shortcode(apply_filters('the_content', get_post_field('post_content', $r->id)));
    		}
    	}
    
    	return $results;
    }

    But very likely this variation will not change anythig, if the shortcode does not exist yet.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.