• Resolved ablackburn85

    (@ablackburn85)


    I have tried disabling all plugins, switched to the twentyseventeen theme, changing the date picker format, changing the number of posts to match, and run through the troubleshooting guide. I cannot get the next month to show up in month view.

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hey @ablackburn85,

    Can you try this snippet → https://gist.github.com/erishel/abac63d3a82f87c57d2003776171bcd6

    You can click download ZIP, then upload as a plugin file, or just copy the function and add_action to your functions.php

    Let me know if that works for you!

    Thread Starter ablackburn85

    (@ablackburn85)

    It didn’t work. The link for the next month isn’t appearing at all for me, but I can switch between months just fine using the date picker.

    I checked the code and it seems like something is preventing the link from being called correctly as it’ not hidden with CSS or anything, it’s just not there.

    Sounds like pagination is not included in your template. You can try to change default events template under Events → Settings → Display to Default Events instead of Page.

    If that doesn’t work, you’ll have to look into creating a custom page template and apply it as global so you can choose it under those settings.

    Thread Starter ablackburn85

    (@ablackburn85)

    So previous month will work without pagination but next month won’t? I tried switching to other templates, no luck. I’ve done custom themes for this plugin before without this issue which is why it seems so strange. I have confirmed that it is pulling the default surrounding code, it’s just not printing the link for the next month.

    <ul class="tribe-events-sub-nav">
    	<li class="tribe-events-nav-previous" aria-label="previous month link">
    		<a data-month="2018-05" href="https://****.******.com/events-calendar/2018-05/" rel="prev"><span>?</span> May </a>	</li>
    	<!-- .tribe-events-nav-previous -->
    	<li class="tribe-events-nav-next" aria-label="next month link">
    			</li>
    	<!-- .tribe-events-nav-next -->
    </ul>
    Anonymous User

    (@anonymized-15094376)

    Bizarrely I’ve found that the following slight tweak “fixes” this. In file src\functions\template-tags\month.php look for function tribe_events_the_next_month_link() and change:

    if ( $date <= tribe_events_latest_date( Tribe__Date_Utils::DBYEARMONTHTIMEFORMAT ) ) {

    to

    if ( $date >= tribe_events_latest_date( Tribe__Date_Utils::DBYEARMONTHTIMEFORMAT ) ) {

    Note the change of comparison operators from <= to >= .

    My apologies, I totally misunderstood the issue here. This is actually due to using a period as a delimiter for dates. The good news is that this bug was fixed in the last release, so all should be good!

    Anonymous User

    (@anonymized-15094376)

    @erishel do you mean it’s been fixed in version 4.6.19 or in a version yet to be released? I’m using version 4.6.19 but if I revert the “fix” I posted previously, the next month link disappears again. If you look at the link posted by [please do not @-ping people], the “August >>” link is missing. That’s how it is with my installation unless I change the comparison operators in function tribe_events_the_next_month_link() .

    I’m not seeing a link from any of your posts, only from the original poster.

    The code that you changed is in place for hiding the next month link if no future events are found in the database — not sure if this is the case here or if this is some sort of plugin/theme conflict (I’m unable to replicate the issue), but give this snippet a shot in your child theme’s functions.php file:

    	        add_filter( 'tribe_events_the_previous_month_link', array( $this, 'previous_month' ) );
    	    }
    	    public function next_month() {
    	        $url = tribe_get_next_month_link();
    	        $text = tribe_get_next_month_text();
    	        $date = Tribe__Events__Main::instance()->nextMonth( tribe_get_month_view_date() );
    	        return '<a data-month="' . $date . '" href="' . $url . '" rel="next">' . $text . ' <span>&raquo;</span></a>';
    	    }
    	    public function previous_month() {
    	        $url = tribe_get_previous_month_link();
    	        $text = tribe_get_previous_month_text();
    	        $date = Tribe__Events__Main::instance()->previousMonth( tribe_get_month_view_date() );
    	        return '<a data-month="' . $date . '" href="' . $url . '" rel="prev"><span>&laquo;</span> ' . $text . ' </a>';
    	    }
    	}
    	new ContinualMonthViewPagination;
    }

    Hope that helps!

    Anonymous User

    (@anonymized-15094376)

    Hi Ed,

    My last post was moderated because I stupidly pinged you and the OP (sorry Jan, Steve – I’m not used to posting in forums). Anyway, I get what you’re saying. It is by design that the next month link does not show up if there are no future events – and that was the issue in my case. That’s fair enough but to me it looks a bit odd. Visitors to the site may not know that there are no future events and could be looking for the next month link so it is my preference that the next month link is always visible.

    Thank you for the code. I’m not sure what happened but it is incomplete but I got it sorted anyway. Here’s the full code I added the functions.php:

    if ( class_exists( 'Tribe__Events__Main' ) ) {
    	class ContinualMonthViewPagination {
    		function __construct() {
    			add_filter( 'tribe_events_the_next_month_link', array( $this, 'next_month' ), 0 );
    			add_filter( 'tribe_events_the_previous_month_link', array( $this, 'previous_month' ), 0 );
    		}
    		
    	    public function next_month() {
    	        $url = tribe_get_next_month_link();
    	        $text = tribe_get_next_month_text();
    	        $date = Tribe__Events__Main::instance()->nextMonth( tribe_get_month_view_date() );
    	        return '<a data-month="' . $date . '" href="' . $url . '" rel="next">' . $text . ' <span>&raquo;</span></a>';
    	    }
    
    		function previous_month() {
    			$url = tribe_get_previous_month_link();
    			$text = tribe_get_previous_month_text();
    			$date = Tribe__Events__Main::instance()->previousMonth( tribe_get_month_view_date() );
    			return '<a data-month="' . $date . '" href="' . $url . '" rel="prev"><span>&laquo;</span> ' . $text . ' </a>';
    		}
    	}
    	new ContinualMonthViewPagination;
    }

    This works fine for me. Thanks again.

    Awesome! Glad you got it figured out.

    I’m going to go ahead and close out this thread — don’t hesitate to create a new one any time you need help!

    Take care,
    Ed ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Next Month Link Not Showing’ is closed to new replies.