Add meta tags when block exist on page and its cached I have block with social sharing buttons. Need add 'og' and 'twitter' meta tags on page where block exists. I know that can add it throw drupal_add_html_head() inside block content render, but if block is cached meta tags not appear.
How do this?
Instead of adding php code in the block you could add the code in a preprocess function for the block.

/**
 * Implements template_preprocess_block().
 */
function MYTHEME_preprocess_block(&amp;$variables) {
  if ($variables['block']-&gt;bid == 'MYBLOCKID') {
    $og_title = array(
      '#tag' =&gt; 'meta',
      '#attributes' =&gt; array(
        'property' =&gt; 'og:title', 
        'content' =&gt; "My example title",
      ),
    );
    drupal_add_html_head($og_title, 'MYMODULE_og_title');
  }
}