Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Customize Display number of posts
This topic contains 11 replies, has 2 voices, and was last updated by Ernest Marcinko 1 week, 4 days ago.
- AuthorPosts
- March 16, 2023 at 12:51 pm #41805
Hi Ernest,
I’ve just purchase your plugin and have a question: is it possible to customize in the live search results the “Display the number of posts associated with the terms”? Each post is on my site a coupon and I’d like to add the word “Gutscheine” after the number. So at the moment it looks like this: https://imgur.com/a/lUkFwYC and I’d like that it looks like this: https://imgur.com/a/gnpSRRi. So also 2 lines and align it vertical centered to the image. Is it possible?
And if possible to add this also for the result page https://imgur.com/a/fdUadlA , but there is an additional problem with the image of the store. In the image options I’ve to add the custom field for this https://imgur.com/a/ieqUWnv This is working fine for the live search, but not for the search result page.
Thanks and best regards
March 17, 2023 at 1:43 pm #41827Hi,
Thank you for all the information, it helps a lot!
With a bit of custom code some of this might be possible. The easiest one is to center the text with the images, for that all you need is this cusomt CSS:
.asp_content .asp_res_url { padding-top: 10px !important; }
With that, to put the number of affected post to the descripion, the below custom code will do the trick. Try adding this code 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_results', 'asp_change_term_count'); function asp_change_term_count($results) { foreach($results as $k=>&$r){ if ( isset($r->taxonomy) ) { $term = get_term_by('id', $r->id, $r->taxonomy); if ( $term->count > 1 ) { $v->content = $term->count ." Gustscheine"; } else { $v->content = "Ein Gustscheine"; } } } return $results; }
The results page images is a bit more complicated thing, it may need custom coding for your theme. The plugin tries to change the result images for the results page, but many times they are requested from the WordPress core, and generally taxonoym terms do not belong to the results page, so WordPress simply returns an empty string as if there is no image.
The only way to get by that is by changing the theme source, and trying to implement the plugins theme functions to fetch the original image. I only recommend starting with this if you have extensive programming knowledge, otherwise it is better to ask a developer to do it.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 17, 2023 at 3:26 pm #41838Hi Ernest,
thank you very much for the code!
To center the text is working, but if I put the other code to my functions.php from the child theme, I’ve got this error at the search https://imgur.com/a/G8SrVMR And do I’ve also to switch this description on https://imgur.com/a/CIpuL8u to show the count + text? Because I’ve already text in the description field (some text about the store) and it would look like this https://imgur.com/a/ABNxVgI if I enable it.
The problem with the result page I’ll check with the developer of the Rehub theme, thanks for the hint.
Best regards
March 17, 2023 at 4:15 pm #41846No need to turn on the description if you only want the count as on the screenshot. There is probably an error in the code above, can you please try this variation instead:
Best,add_filter('asp_results', 'asp_change_term_count'); function asp_change_term_count($results) { foreach($results as $k=>&$r){ if ( isset($r->taxonomy) ) { $term = get_term_by('id', $r->id, $r->taxonomy); if ( $term->count > 1 ) { $r->content = $term->count ." Gustscheine"; } else { $r->content = "Ein Gustscheine"; } } } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 17, 2023 at 4:29 pm #41848Thanks, the error is no longer there but there is also no change https://imgur.com/a/SE6353l
Do you need maybe access to my site to check it?March 17, 2023 at 4:32 pm #41849Can you try enabling the results description? I may have mistaken, it may need to be enabled.
Best,
If it does not work, then you can add details and I will log in an check.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 17, 2023 at 4:42 pm #41850https://imgur.com/a/Iyxj9y4 🙂 🙂 🙂
Yes I’ve to enable the result description, now it’s working perfectly! Hope I can also solve this on the results page.
Thank you very much und best regards!
March 18, 2023 at 3:57 pm #41864You are very welcome 🙂
For the results page it is only possible by directly ediging the theme files, I only recommend doing that if you have programming knowledge. If you want, I can take a look at it for you, but I can’t guarantee anything.
For that please add temporary FTP and back-end details, so I can access the theme files for editing.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 19, 2023 at 6:00 pm #41882You cannot access this content.March 20, 2023 at 12:55 pm #41890Thank you Jörg,
I think I found a way, it was not too complicated. I have added a few lines to
Best,\wp-content\themes\rehub-blankchild\inc\parts\compact_grid.php
file, which already existed in the child theme directory.
Now the images are fetched from ajax search pro, and printed if they exist.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 20, 2023 at 7:39 pm #41899You cannot access this content.March 21, 2023 at 1:33 pm #41906You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.