• Resolved jurez123

    (@jurez123)


    Hi!
    I’m building a tutoring website, and I’ve found your plugin to be useful in creating reviews for the instructors. It works great with using the [ratemypost-result] shortcode in archive pages with Anywhere Elementor, so you can feel free to add that to compatible plugins. Thank you for the great plugin!
    Anyway, here’s the issue I’ve run into. I’d like the ratings to be displayed inside the ajax search ratings of the JetSearch plugin, as that would look simply brilliant. Unfortunately, the shortcode placed in the plugin template loop doesn’t fetch any data.
    Is there anything I’m doing wrong?

    Here’s the code that’s in the plugin editor:

    <?php
    /**
     * Results Item js template
     */
    ?>
    
    <div class="jet-ajax-search__results-item">
    	<a class="jet-ajax-search__item-link" href="<code>data.link</code>" target="<code>data.link_target_attr</code>">
    		<code>data.thumbnail</code>
    		<div class="jet-ajax-search__item-content-wrapper">
    			<code>data.before_title</code>
    			<div class="jet-ajax-search__item-title"><code>data.title</code></div>
    			<code>data.after_title</code>
    			<?php echo do_shortcode('[ratemypost-result]'); ?>
    			<code>data.before_content</code>
    			<div class="jet-ajax-search__item-content"><code>data.content</code></div>
    			<code>data.after_content</code>
    			<code>data.rating</code>
    			<code>data.price</code>
    		</div>
    	</a>
    </div>
    

    You’ll find the php shortcode echo line in between the data.after_title and data.before_content stuff.
    You can type in “hrv” in the search. Also, under it there’s a post archive where you can see the post ratings being displayed correctly.
    Let me know, thanks!

    • This topic was modified 3 years, 11 months ago by jurez123.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Blaz K.

    (@blazk)

    Hi @jurez123,

    I’m happy to hear you like the plugin. RMP initializes rating/results widgets on page load. Since you are adding results widget in ajax search they are no present in DOM on page load and thus they don’t get initialized. But there is a solution for that ?? You can use the RateMyPost.re_init(); JS function. This function was initially added for compatibility with infinitive scroll plugins but should work just fine also in your case. So basically after search results are loaded you need to call RateMyPost.re_init(). See the example in the documentation for more info.

    Regards,
    Blaz

    Thread Starter jurez123

    (@jurez123)

    Hi Blaz, I actually managed to solve this issue now.:D
    I’ve figured out that the AJAX would indeed be a problem here. That’s why I tried to find out where the stuff that’s outside of the loop gets called back in. I’m no expert in this, so excuse my lack of proper terminology!

    I went in the file ajax-handlers.php and added a new line of code:
    ‘reviews’ => do_shortcode(‘[ratemypost-result id=”‘.$post->ID.'”]’),

    and inserted it back in the template php file with
    data.reviews

    That worked like a charm.Thank you for the fast response!

    Kind Regards,
    Jure

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘JetSearch AJAX functionality issue’ is closed to new replies.