如果该代码没有错误,该如何关闭?

时间:2018-07-21 18:26:37

标签: php wordpress function meta-tags

此代码我创建了此代码,以便仅对所有网站页面(首页和关于&联系&博客&... etc)的帖子标头添加元关键字标签 我将此代码添加到function.php中,每次遇到错误时都必须关闭,如果使用endif函数,并且每次尝试时都遇到错误..所以请帮忙

{       
        "hallName": "Small hall",
        "movieName": "Moonwalker - Michael jackson" 
        "takenSeats": [],
        "_id": "5b428d6b9d5b8e4228d14229",
        "showDate": "7/10/2018",
        "showStartTime": "4:00 PM",
        "showEndTime": "6:00 PM",
}

1 个答案:

答案 0 :(得分:1)

您忘记关闭该功能

add_action('wp_head', function (){
  if ( is_single() ) { 
    echo get_post_meta( get_the_ID(), 'meta-head', true ); 
    $postTags = get_the_tags(); 
    $tagNames = array(); 
    foreach($postTags as $tag) { 
      $tagNames[] = $tag->name; 
     } 
     ?> 
     <meta name="keywords" content="<?php echo implode($tagNames,","); ?>" /> 
  <?php 
  }
 } // This one here