Fix for Next Events / More Events no longer working

Home Forums Calendar Products Events Calendar PRO Fix for Next Events / More Events no longer working

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1056222
    Benjamin
    Participant

    I had followed the fix recommended in this post:

    Modify Previous Events & Next Events Pagination

    To change the “next events” pagination link to “more classes,” but this approach which adds an argument to the functions file no longer works with the most recent update of The Events Calendar.

    Please advise.

    Thanks!

    #1056252
    George
    Participant

    Hey @Benjamin!

    Thanks for reaching out.

    That thread is indeed quite outdated, and its code is not valid. Our plugins are coded much differently these days, and so the first thing you’d need to is use the code from this article to change the word “Events” to “Classes” → https://theeventscalendar.com/knowledgebase/changing-the-word-events-to-something-else/

    Once that’s done, you can change the word that precedes “Event/s” by adding this code snippet to your theme’s functions.php file below the code from the above article:


    function tribe_custom_theme_text( $translations, $text, $domain ) {

    $custom_text = array(
    'Previous %s' => 'Older %s',
    'Next %s' => 'More %s',
    );

    if ( array_key_exists( $text, $custom_text ) ) {
    $text = $custom_text[ $text ];
    }

    return $text;
    }

    add_filter( 'gettext', 'tribe_custom_theme_text', 20, 3 );

    If you use both principles together, instead of “Previous Events” and “Next Events” you will have “Older Classes” and “More Classes”, respectively.

    Now, you do not have to use “Older Classes”, of course, that’s just an example of how you could change the “Previous” text to something else.

    If you only to change the “Next” text to “more”, then you can just make that $custom_text variable above look like this instead of what you see in the above snippet:


    $custom_text = array(
    'Next %s' => 'More %s',
    );

    I hope this all helps!

    — George

    #1056253
    Benjamin
    Participant

    George, thank you for your quick response!

    The first step (changing Events to Classes) works for me, but when I added the snippet of code you’ve included below that I get a syntax error.

    Here’s everything as I currently have it:

    add_filter( ‘tribe_event_label_singular’, ‘event_display_name’ );
    function event_display_name() {
    return ‘Class’;
    }

    add_filter( ‘tribe_event_label_plural’, ‘event_display_name_plural’ );
    function event_display_name_plural() {
    return ‘Classes’;
    }

    // Change next classes to more classes

    function tribe_custom_theme_text( $translations, $text, $domain ) {

    $custom_text = array(
    ‘Previous %s’ => ‘Older %s’,
    ‘Next %s’ => ‘More %s’,
    );

    if ( array_key_exists( $text, $custom_text ) ) {
    $text = $custom_text[ $text ];
    }

    return $text;
    }

    add_filter( ‘gettext’, ‘tribe_custom_theme_text’, 20, 3 );

    #1056264
    George
    Participant

    I’m sorry to hear this! I do not have a syntax error and cannot spot a specific error in your code as you’ve copied-and-pasted it; can you copy-and-paste the actual error itself?

    Apologies for the added step here; not sure what’s happening with this error but once I see the full text of the error I might be able to spot the issue.

    Thanks for your patience,
    George

    #1056288
    Benjamin
    Participant

    George,

    It has something to do with these lines:

    ‘Previous %s’ => ‘Older %s’,
    ‘Next %s’ => ‘More %s’,

    Because when I remove it, it works.

    When I leave that line in the code, my browser throws this error:

    Parse error: syntax error, unexpected ‘=’, expecting ‘)’ in /home3/ab58849/public_html/wp-content/themes/fropo/functions.php on line 29

    #1056722
    George
    Participant

    Hm, I again do not have this error so I am wondering – can you copy and paste your entire functions.php file into a Gist at http://gist.github.com and then share a link here to that Gist?

    I’ll take a look and see what I can learn.

    Thank you,
    George

    #1056912
    Benjamin
    Participant

    Here’s a link to the code from my functions file:

    https://gist.github.com/anonymous/b58649144f442dde6c03

    Thanks for taking a look!

    #1058162
    George
    Participant

    Thanks Benjamin!

    The problem is this:

    You cannot have this in the file there:

    =& gt;

    You need to have this:

    =>

    I hope this clears things up with that snippet; it should work well!

    Thanks for your patience here,
    George

    #1058915
    Benjamin
    Participant

    Thanks George, that did the trick!

    #1059394
    George
    Participant

    Nice! Best of luck with your site 🙂

    George

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Fix for Next Events / More Events no longer working’ is closed to new replies.