Recurring events/main loop/functions.php/and settings :)

Home Forums Calendar Products Events Calendar PRO Recurring events/main loop/functions.php/and settings :)

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1147833
    Jennifer Findley
    Participant

    I am SO close to figuring this out using the forums and the docs… so thank you guys for having so many resources available.

    However – I can’t get past one thing…

    I successfully integrated the events into the main loop even though its a custom query..

    Then I successfully got the events to show in their published date order… by adding to the functions.php file…

    *BUT having the ‘recurring events’ checkbox checked in settings kills the whole loop. So that portion of the homepage goes blank.

    This has only happened after adding to the functions file… The piece that fixed the publish date order by stuff…

    I added this to functions.php:
    ——–
    add_action( ‘pre_get_posts’, ‘tribe_post_date_ordering’, 51 );

    function tribe_post_date_ordering( $query ) {
    if ( ! empty( $query->tribe_is_multi_posttype ) ) {
    remove_filter( ‘posts_fields’, array( ‘Tribe__Events__Query’, ‘multi_type_posts_fields’ ), 10, 2 );
    $query->set( ‘order’, ‘DESC’ );
    }
    }
    ———

    But now I can’t click the recurring events checkbox in settings without it removing the home page loop…

    SO – Is there a function, or an addition to the function above that can eliminate the repeated posts for recurring events… to only show the first one… not all of them in a row… without checking that box?

    Thank you in advance!!!!

    a

    #1147944
    Cliff
    Member

    Hi Jennifer. Just so we’re both on the same page, did you get that code from this forum thread?

    Am I correct in understanding that you’re wanting to display Events within your main blog loop?

    If yes — that this is only implemented on the front-end — what “recurring events” checkbox are you trying to check? Is it in wp-admin somewhere?

    Looking forward to hearing back.

    #1148773
    Jennifer Findley
    Participant

    Thanks for the reply 🙂

    I got the snippet for the function.php file from this forum, but not that thread… here’s what I’m using:
    ———
    add_action( ‘pre_get_posts’, ‘tribe_post_date_ordering’, 51 );

    function tribe_post_date_ordering( $query ) {
    if ( ! empty( $query->tribe_is_multi_posttype ) ) {
    remove_filter( ‘posts_fields’, array( ‘Tribe__Events__Query’, ‘multi_type_posts_fields’ ), 10, 2 );
    $query->set( ‘order’, ‘DESC’ );
    }
    }

    ———–
    And the first part (most important for this issue) of my custom homepage loop:
    ——–
    <?php $args2 = array( ‘post_type’ => array(‘post’,’tribe_events’), ‘posts_per_page’ => 5);
    $args2[‘paged’] = get_query_var( ‘page’ ) ? get_query_var( ‘page’ ) : 1;
    $query2 = new WP_Query( $args2 );
    ——–

    Yes, the goal is to have the events show in the main loop at the time they are published (not the event date)…

    So they now do… but the recurring events show multiples of the same post… So clicking the recurring event instances checkbox in settings blocks the loop completely… ir does something that makes that section of my homepage blank…

    So end goal – is to show events on publish date/time… and only show one instance of a recurring event in the loop…

    Can you point me towards a solution?

    And thank you in advance!!!

    j

    #1148802
    Jennifer Findley
    Participant

    Found this thread: https://theeventscalendar.com/support/forums/topic/override-setting-to-display-first-instance-only-of-recurring-events/

    Could something along these lines help my situation?

    Using [‘tribeHideRecurrence’] in some form?

    Again, just trying to get the recurring events to show the first instance where the checkbox for that feature kills my custom loop.

    Please advise.. and thank you guys!

    #1149241
    Cliff
    Member

    Jennifer, I saw from your previous reply that you’re aware of this setting: https://cl.ly/3b0E0t410I05

    If that’s what you’re wanting except you’re just trying to change the sort order, you might want to reference https://gist.github.com/jazbek/7129020 (it’s an old snippet but it may still work or point you in the right direction for your customization).

    #1149294
    Jennifer Findley
    Participant

    Hi Cliff. Thanks for your reply.

    But thats not what I need…

    I need to only show the first recurring event in a series when posting—-but without checking the settings box.

    #1149345
    Cliff
    Member

    Unfortunately, I’m limited in helping with such customizations, per our Scope of Support / Terms.

    If you need some coding help, you may want to ask your developer or reference our documentation and list of known customizers.

    #1149395
    Brook
    Participant

    Howdy Jennifer,

    Cliff asked the rest of the team if any of us had any ideas or some directions for you. It’s awesome how far you’ve made it!

    I just wanted to ask a clarifying question, when you say recurring events “blocks the loop completely” do you just mean that there are too many recurrences in the main loop causing countless pages to be useless, or that the entire loop is empty/comes back with nothing? If it is just that there are too many recurrences, you could try adding ‘post_parent’ => 0, to your main loop query. This will only include events which have no parent, recurrences events are all children of the initial event.

    If instead the loop is empty or returns no results, it’s probably one of our query hooks in Pro that also needs to go away. You might remove the ‘setup_hide_recurrence_in_query’ like this but only do it when you run your main loop query there Maybe just before you run the query:

    remove_action( 'tribe_events_pre_get_posts', array( Tribe__Events__Pro__Main::instance(), 'setup_hide_recurrence_in_query' ) );

    I was also wondering, did you try the “show event in main blog loop” setting and find it to be insufficient in some way, hence all this modification? If so we’d love to hear your feedback on what more it could do.

    Cheers!

    – Brook

    #1149985
    Jennifer Findley
    Participant

    My main issue was to get recurring events to only show the first instance – without using the checkbox in settings.

    I think this fixed it: ‘post_parent’ => 0,

    THANK YOU BROOK!

    j

    #1150153
    Cliff
    Member

    Awesome job, Brook, and thanks for letting us know, Jennifer. Good work!

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Recurring events/main loop/functions.php/and settings :)’ is closed to new replies.