0

I am using a Wordpress Plugin called 'All-in-one Event Calendar'. The plugin has a option to copy and paste a piece of script and put it in your code. This code will then generate events on the page. The plugin will create one event item for each event post.

My Question: Is there a way to limit this to X amount of posts (in my case 3)? The developers of the plugin aren't able to answer the Wordpress forums and any solutions on the Wordpress forums are from 4 years ago and most of those solutions (for some reason) has been removed by the developers.

Here is the Code that generates the Widget:

<script class="ai1ec-widget-placeholder" data-widget="ai1ec_agenda_widget" data-events_seek_type="events" data-show_subscribe_buttons="false">
  (function(){var d=document,s=d.createElement('script'),
  i='ai1ec-script';if(d.getElementById(i))return;s.async=1;
  s.id=i;s.src='//YOURSITEURL/?ai1ec_js_widget';
  d.getElementsByTagName('head')[0].appendChild(s);})();
</script>

I have tried using some jQuery and Delete all posts after 3 but the posts takes a while to actually load (The load times vary) so I can't target the elements that the plugin creates.

AJAX COMPLETE

$(document).ajaxComplete(function(){
   SCRIPT PROVIDED
});
AJDEV
  • 4,790
  • 3
  • 14
  • 22
  • I'm unfamiliar with this plugin, but in relation to your attempted solution, could you hook that into jQuery's ajaxComplete event so that it runs once everything has loaded? Not the best solution of course, but might help if you can't find another. – Tim Malone May 31 '16 at 03:25
  • @TimMalone Do you mean something like this? (See Edited Question) – AJDEV May 31 '16 at 03:46
  • Yep that's exactly what I was thinking. If you have other things on that page doing Ajax, just be aware this could get called multiple times so just ensure u do appropriate checking in there – Tim Malone May 31 '16 at 03:51
  • So I solved it, what I did was: 1. Set and interval for every 0.5 seconds. 2. Check if the element exists. 3. Once it does, stop the interval. 4. Do whatever I have to do. Thanks for the help as well @TimMalone – AJDEV May 31 '16 at 04:07

0 Answers0