Home › Forums › Calendar Products › Community Events › Getting error Undefined variable: postId
- This topic has 4 replies, 2 voices, and was last updated 6 years, 10 months ago by Christian Thomson.
-
AuthorPosts
-
June 17, 2017 at 10:14 am #1299649Christian ThomsonParticipant
Hello! I’ve recently started getting errors on my website homepage, where it goes down off and on for the past few days. When the page is down, I get the error:
This page isnโt working
valleyfirstaidtraining.ca redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTSSo I created a duplicate copy of the site under https://valleyfirstaidtraining.ca/test_site/ and I updated all plugins there. Because of the too many redirects, I thought to include wp_reset_postdata(); to my two custom queries (Upcoming Events, and getting Events by Location), and it loaded the page, but with errors:
Notice: Undefined variable: postId in /home/valleyfi/public_html/test_site/wp-content/themes/valleyfirstaid/sidebar-home.php on line 31
That refers to the code snippets:
<?php query_posts(array( 'post_type' => 'tribe_events', 'posts_per_page' => 5 ) ); while (have_posts()) : the_post(); $url = esc_url( get_permalink( tribe_get_venue_id( $postId ))); ?> <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3> <p><?php echo tribe_get_start_date($post->ID, true, $format = 'F j, Y - l' );?><br> <?php echo tribe_get_venue_link()?></p> <?php endwhile; wp_reset_postdata(); ?>
and
<?php query_posts(array( 'post_type' => 'tribe_venue ' ) ); while (have_posts()) : the_post(); $url = esc_url( get_permalink( tribe_get_venue_id( $postId ))); ?> <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3> <p><?php echo tribe_get_address(). ',<br>'. tribe_get_city() .', '. tribe_get_stateprovince() .' '. tribe_get_zip() .' '. tribe_get_country(); ?><br> <a href="<?php echo $url; ?>#tribe-events-content">View Courses <i class="fa fa-arrow-circle-right"></i></a></p> <?php endwhile; wp_reset_postdata(); ?>
Are parts of this snippet deprecated? Why is $postID an undefined variable?
Thanks!June 20, 2017 at 2:34 am #1300379AndrasKeymasterHello marwickmarketing,
Thanks for reaching out!
Your snippet looks fine, those functions are not deprecated to the best of my knowledge.
Looks like you don’t have $postId defined. What happens if you try
$post->ID
instead or do a declaration before:$postId = $post->ID
Check this. Meanwhile I’ll also try to get someone more versed in coding to take a look at this.
Cheers,
AndrasJune 20, 2017 at 7:20 pm #1300868Christian ThomsonParticipantHi Andras,
The issue was exactly that! I had figured it out, and forgot to close the thread. I appreciate the good guess ๐
Cheers!
CintiaJune 21, 2017 at 8:05 am #1301050AndrasKeymasterHi Cintia,
Stoked to hear you managed to figure it out! Awesome!
Since this is marked resolved I am going to close this ticket, but if you need anything else related to this topic or another please post a new one in the forum and we will be happy to help you out.
Good luck with your project!
Cheers,
AndrasPS: If you like our plugins, and you didn’t yet do so ๐ we would be happy to receive a review in the wordpress.org repository. Thanks!
https://wordpress.org/support/plugin/the-events-calendar/reviews/
https://wordpress.org/support/plugin/event-tickets/reviews/PS2: We’d be also grateful if you would give us feedback on your satisfaction with support. Just click on one of the classy looking emojis below. ๐ If you can spare a few words, that’s even better. Doublethanks!
-
AuthorPosts
- The topic ‘Getting error Undefined variable: postId’ is closed to new replies.