Hide the empty event list
-
Hi, is it possible to hide the event list from the page when it’s empty (‘No data available in table’)?
Many thanks
-
Hi!
Thanks for reaching out.
We can do this with a bit of JS code.
Would you mind pasting the link to an example of this issue in your site, so we can check it out?
Kind Regards,
-RochHi, this is the link
https://www.tvinsport.it
The event list at the moment is only Serie A event list that I want to hide because there are “No data available”.Many thanks
FedericoHi!
Thanks for the link.
This is the JS code to do it:
<script type="text/javascript"> jQuery(document).ready(function($) { jQuery(".sp-event-list td").each(function(){ var text = jQuery(this).text(); if ( text == "No data available in table") { jQuery(this).parent().parent().parent().parent().hide(); } }); }); </script>You can add it to your site using a plugin like this one:
https://ww.wp.xz.cn/plugins/header-and-footer-scripts/Or add it directly in your theme files (header or footer).
Just keep in mind that this will not hide the title, as doing so will actually remove the entire post you have right now.
We have two options for this:
1) Add a custom class to your titles so we can hide them easily via JS as well.
2) Add the titles via CSS (which will be harder).The first one is probably easier and cleaner.
Thanks!
Thank you very much Roch.
-
This reply was modified 6 years, 2 months ago by
iko47.
I know that I am bothered you and I am really sorry.
My idea is to hide events just in the homepage, in this way I can have only events of “today”.
So in this way I need to hide even the title. How can I do with the first option?
Tell me if it is possible. If it is too complicated, don’t worry. I have really appreciated your help
Thanks
-
This reply was modified 6 years, 2 months ago by
iko47.
Hi!
Don’t worry, let’s go for it.
How are you adding this title right now? Are you using the block editor or the classic editor?
We can add a class there so it is removed with a bit of JS code as well.
Thanks!
Hi Roch,
many thanks.
I am using classic editor
Maybe should it be useful a datepicker?
Hi there!
Thanks for reaching out.
I’ve noticed that you changed your homepage. Do you want to keep this current style?
That’s a good solution indeed, as it will show future events.
Thanks!
Hi Roch,
yes it was a test. Maybe you’re right, this could be a good solution. The only issue that i need to solve is how to match the calendar with Sportspress.
Anyway, thank you so much!
Federico
Hi Federico!
I can see now that you have an event in your homepage.
And when I click it, it opens a blank page. Do you want to redirect that to a SP event?
Thanks!
-
This reply was modified 6 years, 2 months ago by
The topic ‘Hide the empty event list’ is closed to new replies.