Home › Forums › Calendar Products › Events Calendar PRO › Limiting mini calendar widget initial results
- This topic has 6 replies, 3 voices, and was last updated 9 years, 10 months ago by
Cliff.
-
AuthorPosts
-
June 20, 2016 at 12:47 pm #1129464
Pieter Heineken
ParticipantHi there,
I posted about this topic before but wasn’t able to follow up before the post was closed. My previous post is here:
I wanted to limit the number of initial results shown for the widget calendar so I could set the calendar to show say 12 results when a date selected but only show 6 at the initial load. I don’t think its the most elegant solution but I was able to accomplish this by adding
$( '.tribe-mini-calendar-event' ).slice( 6 ).css( 'display', 'none' );to the top of src/resources/js/widget-calendar.js. Now the issue is by editing this file I’m assuming this edit will be wiped out when I update the plugin. Is there a way to make this edit so it won’t be reset?Thanks,
Pieter
-
This topic was modified 9 years, 11 months ago by
Pieter Heineken. Reason: wrong path to file
June 20, 2016 at 8:03 pm #1129603Cliff
MemberHi Pieter. Thanks for your question.
I can strongly advise against editing any of our plugin files.
Instead, I’d suggest using wp_enqueue_script (as long as you use noconflict mode) and hooking into the tribe_events_mini_cal_list_inside_before_loop or tribe_events_mini_cal_list_inside_after_loop action (or a better-suited one depending on your needs).
If you need some coding help, you may want to ask your developer or reference our list of known customizers.
Please let me know if you think I may be of more help.
June 21, 2016 at 9:54 am #1129951Pieter Heineken
ParticipantThanks for your reply. Excuse my ignorance but why can’t I just add the script to functions.php?
function limit_mini_calendar_results() { if ( is_front_page() ) { echo " <script type='text/javascript'> jQuery( document ).ready( function( $ ) { $( '.tribe-mini-calendar-event' ).slice( 6 ).css( 'display', 'none' ); } ); </script> "; } } add_action('wp_footer', 'limit_mini_calendar_results');June 21, 2016 at 10:43 am #1129980Cliff
MemberAfter a quick look, I don’t see anything wrong with that code if it’s working for you, except that you’re adding that script to ALL of your site’s pages, not just when the Mini Calendar widget is on the page.
If it’s working for you, it’s probably just fine.
Is there anything more I can do for you on this topic?
June 21, 2016 at 11:36 am #1130004Pieter Heineken
ParticipantFrom what I can tell the script is only being added to the front page which is the only instance of the mini calendar widget on the site. Thanks for your help – consider the issue resolved.
– Pieter
June 21, 2016 at 2:30 pm #1130083Cliff
MemberAh, yes, that’s correct due to the use of the is_front_page() conditional.
I’m glad things are working as you desire!
-
This topic was modified 9 years, 11 months ago by
-
AuthorPosts
- The topic ‘Limiting mini calendar widget initial results’ is closed to new replies.
