• Resolved Vanderklompen

    (@junedvandersar)


    How to put text on event blocks widget if there is no event yet? like text “No event” or something like that, currently just blank right…

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi there!

    Thanks for reaching out.

    We have 2 options for doing this. I’ll share the simplest one, and we can use a different one in case this one doesn’t work for you.

    You can edit the sportspress/templates/event-blocks.php file. It would be better if you had it in a child theme (so you won’t lose this edit in future updates), but this can be done later.

    BEFORE line 157 or so, where you have this:
    foreach ( $data as $event ) :

    Add this:

    if ( empty($data) ) {
    	echo "New events coming soon!";
    }

    This is by no means perfect, but just a quick way to get it working as you need it to.

    Please try it out and let me know how it works.

    Thanks!

    Thread Starter Vanderklompen

    (@junedvandersar)

    Just tried it, and it worked!
    Glad to see your answer after 2 days of waiting. I really appreciate this.

    by the way, how to give “div class” into text …echo? I mean for styling… as you know I’m not familiar with php, but i could try it.

    Thread Starter Vanderklompen

    (@junedvandersar)

    Ok no problem… I asked mr. Google and solved.

    Thread Starter Vanderklompen

    (@junedvandersar)

    here’s my code, hope useful. Thanks

    if ( empty($data) ) {
    	echo '<div class="nomatches">' . "New events coming soon!" . '</div>';
    }

    Hi there!

    Thanks for your reply and I’m glad to hear that it’s working for you!

    Yes, you can even use this simpler version:

    if ( empty($data) ) {
    	echo '<div class="nomatches">New events coming soon!</div>';
    }

    In case you are curious, we use these dots to combine different variables or text portions. But since you have just one text string, you can add it all at once.

    Now if you need any help moving this to a child theme (so it won’t be lost in future updates) just let me know.

    Thanks!

    Thread Starter Vanderklompen

    (@junedvandersar)

    I’m already moving it to a child theme before as you mentioned in your first reply.

    Anyway, I’ve been following this support page for a long time, so I know the directions about the “child theme” tricks.

    Thanks for the knowledge….

    • This reply was modified 2 years, 11 months ago by Vanderklompen.

    That’s awesome! I’m glad it’s resolved!

    Let us know if you need anything else.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Text if there is no match’ is closed to new replies.