• Resolved MacGreenbear

    (@macgreenbear)


    Besides the actual calendar, I am trying to show a list of events…but only if the event status is set to ‘publish’.

    However, all created events return ‘publish’ even if they are set to ‘draft’ within My Calendar.

    How can I check the status of the event so that only ones that are set to publish return true?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Joe Dolson

    (@joedolson)

    Are you pulling events using WordPress posts, rather than by using the My Calendar event lists? The posts aren’t meant to be pulled independently; they’re more of a data store for My Calendar.

    Thread Starter MacGreenbear

    (@macgreenbear)

    Hi Joe,

    I am trying to do more of a ‘show if there are Events’. So I have the event calendar shortcode ready to be displayed…but I only want to display that if there are ‘published’ events (not ones set to Draft).

    Can you think of a way to do that? Am I overlooking something?

    Thanks in advance…

    Plugin Author Joe Dolson

    (@joedolson)

    Are you trying to set things up so you only show the calendar if there are any events published, regardless of the date of those events, or do you need there to be events within the current month/within the current view parameters of the calendar?

    What I’m not sure about, I guess, is what you consider to be the “no events” scenario.

    Thread Starter MacGreenbear

    (@macgreenbear)

    I am using the shortcode…
    [my_calendar_upcoming before=”0″ after=”5″ show_today=”yes” type=”event” order=”asc”]

    What I am trying to do is a conditional so that if there are no published events, the shortcode (along with some other information) doesn’t show and instead a different message appears.

    I’ve attempted this with if (wp_count_posts('mc-events')->publish > 0 )

    But even Draft events will return true.

    Plugin Author Joe Dolson

    (@joedolson)

    Ah, upcoming events. Is there a reason you’re not using the fallback parameter for the upcoming events shortcode? That sets a block of text to show if there are no events to display.

    Thread Starter MacGreenbear

    (@macgreenbear)

    Thanks for that…but I’m actually trying to do the opposite. I want to display a message when there are published events.

    Any suggestions there?

    Plugin Author Joe Dolson

    (@joedolson)

    The simplest solution off hand would be to test the value of the upcoming events shortcode for the presence of your fallback string, e.g.

    $output = do_shortcode( '[my_calendar_upcoming]' ); // with your arguments, whatever they are.
    // If the fallback string is not present...
    if ( false === stripos( $output, 'My Fallback String' ) ) {
        echo 'the content I want to show';
    }
    echo $output; // echo the shortcode.
    Thread Starter MacGreenbear

    (@macgreenbear)

    Perfect! Thanks Joe!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Event Status’ is closed to new replies.