Forums › Forums › Search & Filter Pro › Using Ajax with custom post type..Shortcode content not displaying
Tagged: ajax
- This topic has 9 replies, 2 voices, and was last updated 5 years ago by Trevor.
-
Anonymous(Private) October 30, 2019 at 12:28 pm #225094
I’m loading custom post types by ajax search. Eveverything is fine apart from when I add a shortcode or an action from the plugin “GD Mylist”
Here is a link http://wordpress-256456-1039656.cloudwaysapps.com/
Hope you can advise me on how to solve this 🙂
Trevor(Private) October 30, 2019 at 2:06 pm #225107Where are you adding the shortcode/action? On the search page or in the posts that you are searching?
Can you explain (maybe using videos or screenshots) what goes wrong? Any image or video you want to show me must be uploaded to a file sharing site and then share the link(s) with me.
Anonymous(Private) October 30, 2019 at 3:55 pm #225144I put it in the loop in the results.php file…
Image ‘0’ in the files shared below has the action highlighted.
1mage ‘1’ has the ‘add to wishlist’ button being rendered as expected on the front end. when loading the page using the results.php file to list the custom posts. However when I select a checkbox in the search form, the result are filtered by ajax, and those results no longer have the add to wishlist button on them..that is shown in image’2′
Trevor(Private) October 30, 2019 at 4:49 pm #225166Ah. I understand.
On initial page load, WordPress runs through the shortcodes and executes them. But, an Ajax load only refreshes part of the page, and whatever code that was run on page load, is not triggered again.
Whilst I can give you some JavaScript that will execute on Ajax refresh, I do not know what that plugin requires to be run again on an Ajax refresh.
It is highly unlikely that the author of that plugin has not been asked this before, but I can see nothing on Google. Our JavaScript looks like this:
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); // call your GD Mylist function here }); }(jQuery));</script>
But for what goes there, you need to ask the plugin author if they can help. They may come back and say, ‘Don’t use Ajax.’
Anonymous(Private) October 31, 2019 at 3:00 am #225205Thanks for your help..managed to get it working, in the end, using a different plugin.
I’m having a slight issue now with the text search input..I have checkbox inputs that are working fine. However, the text input search is reloading the page every time I click near it?
https://wordpress-256456-1039656.cloudwaysapps.com/
That is the link so you can see what I’m talking about, hope you can shed some light.
Regards,
Dave
-
AuthorPosts