title: Sending information when sharing on FB and FB OG , through URL using $_GET not working
body: <p>I created a code that gets information from an API and displays it dynamically.</p>
  <pre><code>   foreach($filtered_listings as $listing){
       get_template_part( 'template-parts/listings/img/image','cover', $listing); 
     }
  </code></pre>
  <p>Inside that template part i create the link this way</p>
  <pre><code>&lt;?php //Get all variables from arrays present in passed args ?&gt; 
  &lt;?php extract($args); ?&gt;
  &lt;a class=&quot;img-frame listings-img-frame&quot; href=&quot;'.$home_url.'/annonce?annonceId='.$info['id'].'&quot;&gt;
  </code></pre>
  <p>So when I am in the page I get the ID of the specific page through $_GET, and diplay the right info.</p>
  <pre><code>  // filter_by_id is Declared in Functions.php
    $listing = array_filter($listings, &quot;filter_by_id&quot;);
    $listing_key= key($listing);
    $this_listing= $listing[key($listing)];
  </code></pre>
  <p>So all of this is working fine and in my variable $this_listing I have the right info and can display it the right way.</p>
  <p>NOW! I am trying to implement some FB crawlers in my function.php file</p>
  <pre><code>function insert_fb_in_head() {
    global $post;
    // Import api data from correspondent file and set variables that will be used and retreived
    include_once &quot;api/api-setup.php&quot;;
    global $listings;
    global $token; 
  
    function filter_by_id($listing) { 
      global $annonceId;
      $annonceId = $_GET['annonceId'];
      return $listing['info']['id'] == $annonceId;
    }
    $listing = array_filter($listings, &quot;filter_by_id&quot;);
    $listing_key= key($listing);
    $this_listing= $listing[key($listing)];
  
    extract($this_listing);
    
    if ( !is_singular()) //if it is not a post or a page
      return;
      echo '&lt;meta property=&quot;fb:app_id&quot; content=&quot;Your Facebook App ID&quot; /&gt;';
      echo '&lt;meta property=&quot;og:title&quot; content=&quot;'.$info['titre'].'&quot;/&gt;';
      echo '&lt;meta property=&quot;og:type&quot; content=&quot;article&quot;/&gt;';
      echo '&lt;meta property=&quot;og:url&quot; content=&quot;' . get_permalink() . '&quot;/&gt;';
      echo '&lt;meta property=&quot;og:description&quot; content=&quot;blablabla&quot;/&gt;';
      echo '&lt;meta property=&quot;og:site_name&quot; content=&quot;site Name&quot;/&gt;';
    if(!has_post_thumbnail( $post-&gt;ID )) { //the post does not have featured image, use a default image
      $default_image=&quot;http://example.com/image.jpg&quot;; //replace this with a default image on your server or an image in your media library
      echo '&lt;meta property=&quot;og:image&quot; content=&quot;' . $default_image . '&quot;/&gt;';
    }
    else{
      $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post-&gt;ID ), 'medium' );
      echo '&lt;meta property=&quot;og:image&quot; content=&quot;' . esc_attr( $thumbnail_src[0] ) . '&quot;/&gt;';
    }
    echo &quot;
    &quot;;
    }
    add_action( 'wp_head', 'insert_fb_in_head', 5 );
  </code></pre>
  <p>This works properly on my website. If I var_dump($this_listing) or the only extracted variable I am using for now for instance $info['titre'] I have the desired information coming up.</p>
  <p>BUT! when I share the url this way of fetching the proper listing id:</p>
  <pre><code>    $annonceId;
      $annonceId = $_GET['annonceId'];
  </code></pre>
  <p>returns an error of undefined variable.</p>
  <p>Notice: Undefined index: annonceId in /var/www/vhosts/wapinails.be/httpdocs/wp-content/themes/divi-child/functions.php on line 64 Notice: Undefined index: annonceId in /var/www/vhosts/wapinails.be/httpdocs/wp-content/themes/divi-child/functions.php on line 64 Notice: Undefined index: annonceId in /v...</p>
  <p>So I get that $_GET is not the right way to go in this case. Any suggestion on how to tackle this ?</p>