"Next Month" or "Previous Month" pagination buttons and #app_schedule anchor

Hi,

When using the “Next Month” or “Previous Month” pagination buttons (shortcode [app_pagination]) while viewing the calendar (shortcode [app_monthly_schedule]), as the page switches to each month the page is navigated to an anchor (#app_schedule). By this happening all of the information above the calendar is moved out of view including the name of the month. I would prefer to not use this anchor as the page is refreshed to view the next or previous month.

How can I accomplish this?

Thanks

  • Tyler Postle
    • Recruit

    Hey Steve,

    Hope you’re doing well today and thanks for the question!

    You can strip out the anchor from the class_app_shortcodes.php file :slight_smile: I’ve made a post previously on this topic here: https://wpmudev.com/forums/topic/automatic-wordpress-upgrade-may-have-messed-up-appointments-pagination#post-780528

    It was for a different issue; however, the same solution should apply for yours. I’ve attached the edited file there too so you can just simply overwrite your current one. Always a good idea to make a copy of the original too just in-case :slight_smile:

    Hope this helps Steve and let us know if you need any further assistance!

    All the best,

    Tyler

  • STEVE
    • Site Builder, Child of Zeus

    Hi Tyler,

    Thanks for the quick reply on this topic. I can easily apply the fix as you instructed. However, I am creating this site for a client. Is there any way we can resolve this in a way that would not require an edit of the class_app_shortcodes.php file every time the app is upgraded? Maybe adding something to the child theme’s functions.php file? Would that be at all possible?

    Thanks

  • Ash
    • Code Norris

    Hello @STEVE

    Just replacing the file is not a good idea after updating. There are possibilities to make some changes in that file. So, if a function is declared in this file in new version and called in another file, and if you replace this file with old one, there will be an error.

    So, what you have to, just apply the changes. You know the changes, what and where to make, you have to do the same after updating the plugin.

    Cheers

    Ash

  • STEVE
    • Site Builder, Child of Zeus

    Thanks for the reply. And I do understand and would definitely edit the file and not replace it. However my other question remains.

    Is there any way we can resolve this in a way that would not require an edit of the class_app_shortcodes.php file every time the app is upgraded? Maybe adding something to the child theme’s functions.php file? Would that be at all possible?

    Thanks

  • STEVE
    • Site Builder, Child of Zeus

    Hello,

    I am finally getting around to making this edit. However the code is slightly different that it apears on that other post Tyler showed me. The code looks like this…

    if ( $prev > $prev_min ) {
    $c .= '<div class="previous">';
    $c .= '<a href="'. add_query_arg( "wcalendar", $prev ) . $hash . '">&laquo; '. $month_week_previous . '</a>';
    $c .= '</div>';
    }
    if ( $next < $next_max ) {
    $c .= '<div class="next">';
    $c .= '<a href="'. add_query_arg( "wcalendar", $next ) . $hash . '">'. $month_week_next . ' &raquo;</a>';
    $c .= '</div>';
    }

    What should I be stripping out?

    Thanks

  • Tyler Postle
    • Recruit

    Hey Steve,

    Hope you’re doing well today!

    In that case you can strip out the $hash. So it will look like this after:

    if ( $prev > $prev_min ) {
    $c .= '<div class="previous">';
    $c .= '<a href="'. add_query_arg( "wcalendar", $prev ) .'">&laquo; '. $month_week_previous . '</a>';
    $c .= '</div>';
    }
    if ( $next < $next_max ) {
    $c .= '<div class="next">';
    $c .= '<a href="'. add_query_arg( "wcalendar", $next ) .'">'. $month_week_next . ' &raquo;</a>';
    $c .= '</div>';
    }

    Try that :slight_smile:

    Let us know if you need any further assistance!

    Cheers,

    Tyler

  • Michael
    • The Crimson Coder

    Hi everyone, hi steve and tyler,

    FYI and in case anyone else needs this workaround. I don’t like to mess around with plugin files since obviously when the plugin updates, you can start all over again. Therefor: a quick jQuery solution:

    $('a').each(function(){
    this.href = this.href.replace('#app_schedule', '');
    });

    Basically this is saying: for each link, edit this link by replacing the id ‘app_schedule’ by nothing.

    Although still a beginner, I think the code is quite ok. It works for me.

    kind regards,

    Michaël