Forum Replies Created
-
AuthorPosts
-
FilipParticipant
Updating the code for my (yes, sorry it was my widget code indeed) using the updated template from the plugin folder restored functionality. Nevertheless I’d rather have it throw an error message, then state that there are no events planned. Marking this solved, thanks.
FilipParticipantFunctionality of the site has not changed; only updates to the software (WP+plugins) were done. FWIW it’s not my widget but yours đ This installation has been stable for years, as the client just published stuff. Customization of template is not that extensive; we just run a couple of queries here and there, nothing that might touch or conflict otherwise IMO. Please share your thoughts, thanks.
FilipParticipantAnd solved, apparently there setup_postdata does not prevent having to call $event->ID all the time and echoing works better than just outputting results. Phew. In comparison this is what the competion needs for about the same result
echo do_shortcode([event_list limit=3 category="3"]);
FWIW we run php5.5 local and php5.4 remote; nothing too outdated for that, as I’m sure you agree.
As for documentation: I’d focus on theme developers, the documentation is either too simple/generic, or too hardcore and riddled with links to the codex. For this specific issue there were at least 4 possible solutions, both inside and outside the documentation. That just confuses people, I’m sure.
FilipParticipantOk, thumbnails were outside of foreach, so those work (my bad). The dates are probably correct, now only for the titles (and permalinks).
FilipParticipantOK, so now I do this
<div id="stadspodium"> <? // Retrieve events $events = tribe_get_events( array( 'posts_per_page' => 3, 'tax_query' => array( array( 'taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => array('grotekerkplein'), 'operator' => 'NOT IN' ) ), 'start_date' => new DateTime() ) ); // setup thumbnails $spr_id = get_post_thumbnail_id($event->ID); $spr_url = wp_get_attachment_image_src($spr_id,'medium'); $spr_url = $spr_url[0]; // Loop through the events, displaying the title foreach ( $events as $event ) { ?> <article style="background: url(<? echo $spr_url ?>) center no-repeat; background-size: cover"> <div class="meta"> <!--what--> <? echo str_replace( ':', '', tribe_get_event_categories($event->ID, array('label'=>'')) ); ?> <!--when--> <?php if (tribe_get_start_date() !== tribe_get_end_date() ) { ?> <span class="when"> <?php echo tribe_get_start_date($event->ID, false, 'j F Y H:i'); ?> - <?php echo tribe_get_end_date($event->ID, false, 'H:i'); ?> <?php } else { ?> <?php echo tribe_get_start_date($event->ID, false, 'j F Y H:i'); ?> <?php } ?></span> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a></h1> </div> </article> <?} ?> </div> <div id="grotekerk"> <? // Retrieve upcoming events $events = tribe_get_events( array( 'posts_per_page' => 4, 'tax_query' => array( array( 'taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => array('grotekerkplein'), 'operator' => 'IN' ) ), 'start_date' => new DateTime() ) ); // setup thumbnails $gkp_id = get_post_thumbnail_id($event->ID); $gkp_url = wp_get_attachment_image_src($gkp_id,'medium'); $gkp_url = $gkp_url[0]; // Loop through the events, displaying the title foreach ( $events as $event ) { ?> <article style="background: url(<? echo $gkp_url ?>) center no-repeat; background-size: cover"> <div class="meta"> <!--what--> <? echo str_replace( ':', '', tribe_get_event_categories($event->ID, array('label'=>'')) ); ?> <!--when--> <?php if (tribe_get_start_date() !== tribe_get_end_date() ) { ?> <span class="when"> <?php echo tribe_get_start_date($event->ID, false, 'j F Y H:i'); ?> - <?php echo tribe_get_end_date($event->ID, false, 'H:i'); ?> <?php } else { ?> <?php echo tribe_get_start_date($event->ID, false, 'j F Y H:i'); ?> <?php } ?></span> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a></h1> </div> </article> <?} ?> </div>
This gets me 3 events with the same featured image and the wrong events in Stadspodium, and in Grotekerkplein the same 4 events with another featured image, and supposedly the right category (but when in fact: the wrong category). Please help me solve this mess, so I can move on to profitable projects. Thanks.
FilipParticipantNevermind; please refer to my previous post.
- This reply was modified 8 years, 8 months ago by Filip. Reason: Caching issue prevented proper display for this substep (not the original issue)
FilipParticipantWhen you say âfirstâ loop, do you mean that you have more than one query for events on the page? Thatâs fine, but you can also add those category exclusion parameters from the snippet you referenced above directly into the query youâve been working on here with Brian.
I tested this but it does not work,
It is my assumption that tribe_get_events is another form of get_posts and as per codex I cannot filter out a taxonomy in get_posts.
My initial code used wp_query, but I was told that I’d be better off using tribe_get_events. And now I get even more code. Althought I appreciate the support (i am a paying customer) it bothers me that the documentation is so fragmented and ambivalent.
Please guide me to a final solution quickly as the issue is viewable on a live site.
When you say âfirstâ loop, do you mean that you have more than one query for events on the page?
As is viewable on the live site, of which I had to input the url when making this support request in the first place.
FilipParticipantAnd I’d like to know how I can exclude a category for the first loop on the page.
$events = tribe_get_events( array( 'posts_per_page' => 4, 'tax_query' => array( 'taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => 'grotekerkplein', 'operator' => 'NOT IN' ), //'tribe_events_cat' => 'grotekerkplein', 'start_date' => new DateTime() ) );
I tested this but it does not work,
FilipParticipantWell that works, but still leaves me with this error message
Warning: strtotime() expects parameter 1 to be string, object given in /media/sites/www.clientname.dev/wp-content/plugins/the-events-calendar/src/Tribe/Query.php on line 223
FilipParticipantAnd back to square one
<div id="grotekerk"> <? // Ensure the global $post variable is in scope global $post; // Retrieve the next 5 upcoming events $events = tribe_get_events( array( 'posts_per_page' => 4, 'category_name' => 'grotekerkplein', 'start_date' => new DateTime() ) ); // Loop through the events: set up each one as // the current post then use template tags to // display the title and content foreach ( $events as $post ) { setup_postdata( $post ); // This time, let's throw in an event-specific // template tag to show the date after the title! echo '<article><div class="meta">'; echo str_replace( ':', '', tribe_get_event_categories($post->ID, array('label'=>'')) ); echo tribe_get_start_date($post->ID, false, 'j F Y H:i'); echo '<h1>'.get_the_title().'</h1>'; echo '</div></article>'; } ?>
Gives 4 copies of the same event.
FilipParticipantI discovered that if I do strtotime(‘now’) I get no results, and when I do ‘new DateTime()’ I get the PHP error ‘strtotime() expects parameter 1 to be string’. Please advise, thanks.
FilipParticipantOk, I have the code below, but nothing shows.
<? // Retrieve the next 5 upcoming events $events = tribe_get_events( array( 'posts_per_page' => 4, 'taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => 'grotekerkplein', 'operator' => 'IN', 'start_date' => strtotime('now') ) ); // Loop through the events, displaying the title // and content for each foreach ( $events as $event ) { ?> <article style="background: url(<? echo $spr_url ?>) center no-repeat; background-size: cover"> <div class="meta"> <!--what--> <? echo str_replace( ':', '', tribe_get_event_categories($post->ID, array('label'=>'')) ); ?> <!--when--> <?php if (tribe_get_start_date() !== tribe_get_end_date() ) { ?> <span class="when"> <?php echo tribe_get_start_date($post->ID, false, 'j F Y H:i'); ?> - <?php echo tribe_get_end_date($post->ID, false, 'H:i'); ?> <?php } else { ?> <?php echo tribe_get_start_date($post->ID, false, 'j F Y H:i'); ?> <?php } ?></span> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a></h1> </div> </article> <?} ?>
When I leave out `’taxonomy’ => ‘tribe_events_cat’,
‘field’ => ‘slug’,
‘terms’ => ‘grotekerkplein’,
‘operator’ => ‘IN’,`
it still shows nothing. Please advise, thanks.- This reply was modified 8 years, 8 months ago by Filip.
FilipParticipantWell, I tried this (on local installation) and what do you know, an old bug resurfaced `
Warning: strtotime() expects parameter 1 to be string, object given in /media/sites/www.clientname.dev/wp-content/plugins/the-events-calendar/src/Tribe/Query.php on line 223
`
As stated 8 months ago Apparently documentation was not updated. Will apply own fix, then report back.FilipParticipantI tried that on the rightmost eventlist, and indeed it changed the order but now shows events that already have passed. I did not change the calendar on the left. Please advise, thanks.
FWIW; your solution is contrary to documentation, correct?
-
AuthorPosts