Custom code to add meta tag in Drupal 7

22
April

Custom code to add meta tag in Drupal 7
By: Anonymous | Published On: Wed, 04/22/2020 - 22:13

In your theme's template.php file, you could add something like **/

/**
 * Implements hook_preprocess_html
 */
function THEME_NAME_preprocess_html(&$vars) {

  if (current_path() == 'my/custom/path') {
    $description = array(        
      '#type' => 'html_tag',
      '#tag' => 'meta',
      '#attributes' => array(
        'name' => 'description',
        'content' => 'here all description goes',
      )
    );
    drupal_add_html_head($description, 'description');
  }

}

Comments

Need Help ?