• teflonmann

    (@teflonmann)


    At first thanks for your very well made plugin. It is a joy to work with.

    We are currently working on some pages like “Today’s events” where we display the today’s events of course. But we do not have events on each day so the eventlist on the page sometimes remains empty. It would be great to have a “fallback message”, where we could display “Today no shows are scheduled.”. Currently I can only think of creating a custom shortcode, that triggers your shortcode and creates the message if the result is empty. But It would be more convinient, if I could enter the message as a parameter of your shortcode. Is this a thing you could consider implementing? Or is it already possible and I missed it in your documentation?

    Best regards,

    Karsten

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jeroen Schmit

    (@slimndap)

    Hi Karsten,

    You are right, this feature is absolutely missing right now.

    My preferred way of handling this is through one of the many filters that are in place. For example: https://github.com/slimndap/wp-theatre/blob/master/functions/wpt_listing.php#L284

    You can use is to inspect the value of $html and then return your fallback message if there are no events.

    Untested code:

    add_filter( 'wpt_listing_html', function( $html, $args ) {
    if ( !empty( $html ) ) {
    return $html;
    }

    return '<p>My fallback message</p>';

    } );

    Thread Starter teflonmann

    (@teflonmann)

    Hi Jeroen,

    thank you for your reply. You solution at least gives me the opportunity to display a general message for the “list is empty case”.

    I guess for more specific ones for each page I would have to handle current post IDs here in this function as well. And this is a bit of an “error magnet” in my opinion. So I’d rather wait for a shortcode parameter, in case you put it on your roadmap.

    Best regards,

    Karsten

    • This reply was modified 8 months ago by teflonmann.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Feature Request: Alternative Message when Shortcode delivers empty list’ is closed to new replies.