• Resolved iko47

    (@iko47)


    Hi, is it possible to hide the event list from the page when it’s empty (‘No data available in table’)?

    Many thanks

Viewing 11 replies - 1 through 11 (of 11 total)
  • Roch

    (@rochesterj)

    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,
    -Roch

    Thread Starter iko47

    (@iko47)

    Hi, 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
    Federico

    Roch

    (@rochesterj)

    Hi!

    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!

    Thread Starter iko47

    (@iko47)

    Thank you very much Roch.

    • This reply was modified 6 years, 2 months ago by iko47.
    Thread Starter iko47

    (@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.
    Roch

    (@rochesterj)

    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!

    Thread Starter iko47

    (@iko47)

    Hi Roch,

    many thanks.

    I am using classic editor

    Thread Starter iko47

    (@iko47)

    Maybe should it be useful a datepicker?

    Roch

    (@rochesterj)

    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!

    Thread Starter iko47

    (@iko47)

    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

    Roch

    (@rochesterj)

    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!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Hide the empty event list’ is closed to new replies.