如果该代码的功能没有错误,如何关闭?
how to close if fuction of that code without error?
我创建的这段代码是为了仅为帖子添加元关键字标签 header 并排除所有网站页面(主页、关于、联系、博客等)
我将此代码添加到 function.php,每次我遇到错误,如果使用 endif 函数我必须关闭,每次我尝试我都遇到错误..所以请帮助
add_action('wp_head', function (){
?>
<?php
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
}
您忘记关闭功能了
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
我创建的这段代码是为了仅为帖子添加元关键字标签 header 并排除所有网站页面(主页、关于、联系、博客等) 我将此代码添加到 function.php,每次我遇到错误,如果使用 endif 函数我必须关闭,每次我尝试我都遇到错误..所以请帮助
add_action('wp_head', function (){
?>
<?php
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
}
您忘记关闭功能了
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