How to show short description for Pages in results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support How to show short description for Pages in results

This topic contains 13 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 year, 7 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #31818
    malkay72
    malkay72
    Participant

    How can I get the search results box to show the descriptions for normal PAGES on our website. It is only showing pics and short descriptions for Posts (see attached where the top result is the Page ‘Break-through Protection’)

    #31822
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    If your pages have excertps or anything in their description fields, then those would show up. Make sure you have not changerd the primary and secondary description fields here: https://i.imgur.com/CEvO6RM.png
    If the configuration is that, then there is no text within the page excerpts nor their content. If you are using some sort of a page builder, it may store the page contents somewhere else – like a custom field. Try maybe changing this option first: https://i.imgur.com/mtAiVTk.png
    If the descriptions are printed via a shortcode it should help with that. Otherwise I assume it is stored in a meta field of some sort.

    Best,
    Ernest Marcinko

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


    #31826
    malkay72
    malkay72
    Participant

    Unfortunately, that suggestion did not work

    #31827
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Can you add temporary FTP and back-end access to the site? If you want, I can check if there is anything I can do about it.

    Best,
    Ernest Marcinko

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


    #31828
    malkay72
    malkay72
    Participant
    You cannot access this content.
    #31829
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

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


    #31840
    malkay72
    malkay72
    Participant

    Are you wanting FTP access or WordPress admin access? That FTP access I have given above of user: wpdreams and pw: N^e3r37d works fine for me when I check with Filezilla.

    #31854
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Oh, sorry, that actually works, I wanted to try the back-end first.

    Unfortunately I can’t see any content when requesting the page contents from WordPress, it returns simply nothing at all, an empty string. If you want, I can try checking the back-end for custom fields as well.

    Best,
    Ernest Marcinko

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


    #31880
    malkay72
    malkay72
    Participant

    I’m not an expert in knowing how WordPress pulls the data, so I can’t really comment. You could check the back end. So do you need WordPress login?

    #31895
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

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


    #31924
    malkay72
    malkay72
    Participant
    You cannot access this content.
    #31949
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thanks!

    I may have found a possible solution. I have added the following custom code to the functions.php file in your theme directory. Please keep it there:

    add_filter('asp_results', 'asp_fg_results', 10, 1);
    function asp_fg_results($results) {
    	foreach ( $results as $k => &$r ) {
    		if ( $r->content == '' ) {
    			$groups = acf_get_field_groups(array('post_id' => $r->id));
    			foreach ( $groups as $group ) {
    				$fields = acf_get_fields($group['key']);
    				foreach ( $fields as $field ) {
    					$s = get_field($field['name'], $r->id);
    					if ( !empty($s) ) {
    						$r->content = wd_substr_at_word(strip_tags($s), 150) . '..';
    						break 2;
    					}
    				}
    			}
    		}
    	}
    	return $results;
    }

    The page contents were indeed empty. Everything was build via ACF, which is unfortunately not searchable and is not returned when requesting the post content. The function above should take care of it to some extent.

    Best,
    Ernest Marcinko

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


    #31970
    malkay72
    malkay72
    Participant

    That’s very good. Thanks so much for your help

    #31984
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

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


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

You must be logged in to reply to this topic.