tribe_is_month() boolean returning true

Home Forums Calendar Products Events Calendar PRO tribe_is_month() boolean returning true

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #54026
    Cinch
    Participant

    Using Widget Logic, tribe_is_month returns true always.

    It also returns true when testing as such:

    <?php if (tribe_is_month() ) { ?>
    <p>Yo, it's working, or maybe it's not! </p>
    <?php } ?>

    The goal is to have a widget only show on the main calendar page (month view) and any other time a month view is shown. Currently it’s showing on every page.

    There may be other conditionals that could work as well, if anyone has ideas.

    Thanks,
    ~ Bryan

    #54034
    Barry
    Member

    Hi Bryan,

    I don’t have a copy of widget logic to hand but that isn’t what I find when I do my own testing. Besides your use of the conditional in widget logic, where else are you applying this (such as in your example)?

    Using it too early, or too late, could possibly return an erroneous result.

    #54040
    Cinch
    Participant

    Hi Barry,

    Widget Logic is the only place I need to use this conditional. The example above was just a test run in a widget to see if it fires, which it did, even when not on a month view page. Perhaps that conditional is only available within the context of the plugin?

    How would you go about displaying a widget only on the main calendar page?

    Thanks for the quick reply,
    ~ Bryan

    #54063
    Barry
    Member

    Great question.

    If tribe_is_month() is called too early in the request (specifically, before the parse_query hook runs) then it will result in a boolean false result regardless of what is actually about to be displayed. Looking at Widget Logic, it makes it’s assessment earlier in the request, hence the problem.

    So alternative approaches here could be to create a different sidebar to be used only on event pages or else you might do something basically similar to Widget Logic, but adapted to work its magic later in the lifetime of the request.

    #54065
    Cinch
    Participant

    I think your approach at conditionally showing the sidebar is the way I’ll go.

    The odd thing is that tribe_is_month() is returning true in this situation. The site is still in heavy development so I can’t say for 100% certainty that nothing else has changed, but this setup worked in the prior version.

    Anyway, I’m off to conditionally show the sidebar. Thanks for the idea.

    ~ Bryan

    #54073
    Cinch
    Participant

    Hi Barry,

    Odd, but this is returning true on every page as well:

    #54074
    Cinch
    Participant

    Sorry… that code snip didn’t work… here it is again:


    if ( tribe_is_month() ) {
    get_sidebar( 'after-content' );
    }

    #54079
    Barry
    Member

    Unfortunately the forum isn’t very tolerant of code, so it’s usually best to use a service like Pastebin, Gist or similar and share a link to it.

    That snippet in your last post looks like it should do the job … can you confirm where you are using it?

    #54082
    Cinch
    Participant

    I’m using it within footer.php

    I’m having a similar conditional issue here: https://theeventscalendar.com/support/forums/topic/cpt-conditionals-for-filters/

    Perhaps I’ve got something more systemic going on.

    Is it possible to downgrade back to v 2.xx? I don’t see it in the downloads.

    #54093
    Cinch
    Participant

    I had a backup and was able to downgrade to v2.0.11 – which has solved all my conditional problems…

    I’ll have to stay at the older version until I can locate the issue.

    If I figure it out I’ll post back here.

    Thanks,
    ~ Bryan

    #54109
    Barry
    Member

    Sorry to hear that – a number of things have changed as of 3.0 won’t carry over without modification.

    As things progress with 3.0 and the community at large – as well as the support team – build up a further body of knowledge it will doubtless become easier to transition.

    As an aside, if you (or anyone else reading this) does need a historical version then please simply email us at pro (at) tri (dot) be with a brief explanation and one of the team will be happy to help.

    #54124
    Cinch
    Participant

    I’d really like to transition now to 3.0 as we’re still in development. Can you think of any reason why normal WP conditionals might simply stop working when using the new version?

    This conditional also isn’t firing correctly:

    if ( get_post_type($post_id) == 'tribe_events' ) { ... }

    #54135
    Barry
    Member

    What is the value of $post_id? I know it seems like an almost too obvious point – but does it definitely relate to an event (how are you obtaining it)?

    Remember that multiple queries and loops sometimes run to construct a single page, so you would need to catch this while the context is still an event related one, if that makes sense.

    #54136
    Cinch
    Participant

    That was actually just a bit of a test… the $post_id there didn’t make a difference and I’ve removed it. Still testing…

    #54138
    Barry
    Member

    OK – I mean if $post_id is set to an appropriate, valid value then that code ought to work as expected.

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘tribe_is_month() boolean returning true’ is closed to new replies.