title: Shortcode in Wordpress causing php below to not function
body: <p>I've written a shortcode to display the posts of a custom post type (containing team member profiles) in a post with the same category assigned to specific team members. The shortcode works perfectly but the php functions (specifically the first if statement) I have in my page template below the content no longer function. Strangely if I remove the first if statement the php below the content displays correctly</p>
  
  <p>My shortcode is:</p>
  
  <pre><code>function team_embed() {
  ob_start();
  global $post;
  // get the domain page category
  $pagecat = get_the_category();
  $CategoryName = $pagecat[0]-&gt;cat_name;
  $slug = $pagecat[0]-&gt;slug;
  $slug1 = $pagecat[0]-&gt;slug;
  $exp = '_experience';
  $experience = $slug1 .= $exp;
  $query = array( 'post_type' =&gt; 'team', 'posts_per_page' =&gt; -1, 'category_name' =&gt; $slug );
  $loop = new WP_Query($query);
  while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post();
      $phone = get_post_meta($post-&gt;ID, 'Phone Number', true);
      $linkedin = get_post_meta($post-&gt;ID, 'Linkedin', true);
      ?&gt;
      &lt;div class="team-embed-wrapper"&gt;
          &lt;div class="team-embed"&gt;
              &lt;h3&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt;
                  &lt;div class="team-embed-thumbnail"&gt;
                      &lt;?php the_post_thumbnail(); ?&gt;
                  &lt;/div&gt;
              &lt;div class="team-embed-excerpt"&gt;
                  &lt;?php
                      if ($phone) { ?&gt;
                          Phone:&amp;nbsp;&lt;?php echo $phone; ?&gt;&lt;br /&gt; &lt;?php }
                      else {}     
                      if ($linkedin) {
                          echo $linkedin; ?&gt;&lt;br /&gt; &lt;?php }
                      else {} ?&gt;
                  &lt;br /&gt;
                  &lt;a href="&lt;?php the_permalink() ?&gt;" class="rm-button"&gt;Read Complete Profile&lt;/a&gt;  
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="team-embed-experience"&gt;
              &lt;strong&gt;&lt;?php echo $CategoryName; ?&gt; domain related experience:&lt;/strong&gt;&lt;br /&gt;
              &lt;p&gt;&lt;?php echo get_field( $experience ); ?&gt;&lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div style="clear:both"&gt;&lt;/div&gt;  
  &lt;?php       
  endwhile;
  $output = ob_get_clean();       
  return $output;
  }
  add_shortcode( 'Team_Embed', 'team_embed' );
  </code></pre>
  
  <p>The code below the page content in my page template (which works when not using the shortcode is:</p>
  
  <pre><code>&lt;!-- Add closures and Case Studies if available --&gt;
  &lt;?php
      // get the category
      $category = get_the_category();
      $firstCategory = $category[0]-&gt;cat_name;
  ?&gt;
  &lt;?php if( get_field('tclosure_add') == 'yes' ): ?&gt;
      &lt;h2&gt;&lt;?php echo $firstCategory; ?&gt; closures&lt;/h2&gt;
      &lt;div class="closure-cat"&gt;
      &lt;?php echo do_shortcode("[pt_view id=1723554lt4 cat='$firstCategory' limit=3]"); ?&gt;
      &lt;a class="rm-button" href="/experience"&gt;View All Company Closures&lt;/a&gt;&lt;/div&gt;
  &lt;?php endif; ?&gt;
  &lt;?php if( get_field('case_studies_add') == 'yes' ): ?&gt;
      &lt;h2&gt;&lt;?php echo $firstCategory; ?&gt; Case Studies&lt;/h2&gt;
      &lt;div class="case-study-embed-wrapper"&gt;
          &lt;?php echo do_shortcode("[pt_view id=2c2b5b7ulr cat='$firstCategory' limit=3]"); ?&gt;
      &lt;/div&gt;
      &lt;a class="rm-button" href="/representative-engagements/#case-studies"&gt;View All Company Case Studies&lt;/a&gt;
      &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>Any Help would be appreciated</p>