Getting error Undefined variable: postId

Home Forums Calendar Products Community Events Getting error Undefined variable: postId

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1299649
    Christian Thomson
    Participant

    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_REDIRECTS

    So 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!

    #1300379
    Andras
    Keymaster

    Hello 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,
    Andras

    #1300868
    Christian Thomson
    Participant

    Hi Andras,

    The issue was exactly that! I had figured it out, and forgot to close the thread. I appreciate the good guess ๐Ÿ™‚
    Cheers!
    Cintia

    #1301050
    Andras
    Keymaster

    Hi 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,
    Andras

    PS: 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!

     

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Getting error Undefined variable: postId’ is closed to new replies.