Customize Display number of posts

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 Ernest Marcinko 1 year, 1 month ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #41805
    Jörg Frommolt
    Jörg Frommolt
    Participant

    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

    #41827
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #41838
    Jörg Frommolt
    Jörg Frommolt
    Participant

    Hi 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

    #41846
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    No 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:

    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;
    }
    Best,
    Ernest Marcinko

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


    #41848
    Jörg Frommolt
    Jörg Frommolt
    Participant

    Thanks, 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?

    #41849
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Can you try enabling the results description? I may have mistaken, it may need to be enabled.
    If it does not work, then you can add details and I will log in an check.

    Best,
    Ernest Marcinko

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


    #41850
    Jörg Frommolt
    Jörg Frommolt
    Participant

    https://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!

    #41864
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    You 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 :)


    #41882
    Jörg Frommolt
    Jörg Frommolt
    Participant
    You cannot access this content.
    #41890
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you Jörg,

    I think I found a way, it was not too complicated. I have added a few lines to \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.

    Best,
    Ernest Marcinko

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


    #41899
    Jörg Frommolt
    Jörg Frommolt
    Participant
    You cannot access this content.
    #41906
    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 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.