错误:杂散结束标记头

时间:2017-05-29 19:30:46

标签: php wordpress validation header w3c-validation

我很难解决Stray end tag head的问题。

<!doctype html>
<html <?php language_attributes(); ?> >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="X-FRAME-OPTIONS" content="ALLOW-FROM" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>
<?php wp_title("|",true, 'right'); ?>
<?php if (!defined('WPSEO_VERSION')) { bloginfo('name'); } ?>
</title>
<link rel='shortcut icon' href='<?php echo get_template_directory_uri(); ?>/img/favicon.ico' type='image/x-icon' />
<?php 
$page_amp_url = get_post_meta(get_the_ID(), 'amp_page_url', TRUE);
if(!empty($page_amp_url)){ 
echo'<link rel="amphtml" href="'.$page_amp_url.'" />';
}
?>
<?php $options = get_option('salient'); ?>
<?php if(!empty($options['responsive']) && $options['responsive'] == 1) { ?>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
<?php } else { ?>
<meta name="viewport" content="width=1200" />
<?php } ?>
<!--Shortcut icon-->
<?php if(!empty($options['favicon'])) { ?>
<link rel="shortcut icon" href="<?php echo nectar_options_img($options['favicon']); ?>" />
<?php } ?>
<?php  if(is_page('5584')){ ?>
<meta property="og:image" content="https://www.accudock.com/wp-content/uploads/2016/11/willy-375x376-375x376.jpg" />
<meta property="og:image:width" content="375" />
<meta property="og:image:height" content="376" />
<meta property="og:image" content="https://www.accudock.com/wp-content/uploads/2016/11/willy1-375x376.jpg" />
<meta property="og:image:width" content="375" />
<meta property="og:image:height" content="376" />
<meta property="og:image" content="https://www.accudock.com/wp-content/uploads/2016/11/Untitled-1-375x376.jpg" />
<meta property="og:image:width" content="375" />
<meta property="og:image:height" content="376" />
<meta property="og:image" content="https://www.accudock.com/wp-content/uploads/2016/11/4x20-floating-dock-375x376.jpg" />
<meta property="og:image:width" content="375" />
<meta property="og:image:height" content="376" />
<?php }?>
<?php wp_head(); ?>
<?php
global $post; 
global $woocommerce; 
//check if parallax nectar slider is being used
$parallax_nectar_slider = using_nectar_slider();

$force_effect = get_post_meta($post->ID, '_force_transparent_header', true);

// header transparent option

$transparency_markup = null;

$activate_transparency = null;

$using_fw_slider = using_nectar_slider();

$using_fw_slider = (!empty($options['transparent-header']) && $options['transparent-header'] == '1') ? $using_fw_slider : 0;

if($force_effect == 'on') $using_fw_slider = '1';


$disable_effect = get_post_meta($post->ID, '_disable_transparent_header', true);

if(!empty($options['transparent-header']) && $options['transparent-header'] == '1') {



$starting_color = (empty($options['header-starting-color'])) ? '#ffffff' : $options['header-starting-color'];

$activate_transparency = using_page_header($post->ID);

$remove_border = (!empty($options['header-remove-border']) && $options['header-remove-border'] == '1') ? 'true' : 'false';

$transparency_markup = ($activate_transparency == 'true') ? 'data-transparent-header="true" data-remove-border="'.$remove_border.'" class="transparent"' : null ;

}

//header vars

$logo_class = (!empty($options['use-logo']) && $options['use-logo'] == '1') ? null : 'class="no-image"'; 

$sideWidgetArea = (!empty($options['header-slide-out-widget-area'])) ? $options['header-slide-out-widget-area'] : 'off';

$sideWidgetClass = (!empty($options['header-slide-out-widget-area-style'])) ? $options['header-slide-out-widget-area-style'] : 'slide-out-from-right';

$fullWidthHeader = (!empty($options['header-fullwidth']) && $options['header-fullwidth'] == '1') ? 'true' : 'false';

$headerSearch = (!empty($options['header-disable-search']) && $options['header-disable-search'] == '1') ? 'false' : 'true';

$headerFormat = (!empty($options['header_format'])) ? $options['header_format'] : 'default';

$mobile_fixed = (!empty($options['header-mobile-fixed'])) ? $options['header-mobile-fixed'] : 'false';

$fullWidthHeader = (!empty($options['header-fullwidth']) && $options['header-fullwidth'] == '1') ? 'true' : 'false';

$headerColorScheme = (!empty($options['header-color'])) ? $options['header-color'] : 'light';

$userSetBG = (!empty($options['header-background-color']) && $headerColorScheme == 'custom') ? $options['header-background-color'] : '#ffffff';

$trans_header = (!empty($options['transparent-header']) && $options['transparent-header'] == '1') ? $options['transparent-header'] : 'false';

$bg_header = (!empty($post->ID) && $post->ID != 0) ? using_page_header($post->ID) : 0;

$bg_header = ($bg_header == 1) ? 'true' : 'false'; //convert to string for references in css

$perm_trans = (!empty($options['header-permanent-transparent']) && $trans_header != 'false' && $bg_header == 'true') ? $options['header-permanent-transparent'] : 'false'; 

$headerResize = (!empty($options['header-resize-on-scroll']) && $perm_trans != '1') ? $options['header-resize-on-scroll'] : '0'; 

$button_styling = (!empty($options['button-styling'])) ? $options['button-styling'] : 'default'; 

$footer_reveal = (!empty($options['footer-reveal'])) ? $options['footer-reveal'] : 'false'; 

$footer_reveal_shadow = (!empty($options['footer-reveal-shadow']) && $footer_reveal == '1') ? $options['footer-reveal-shadow'] : 'none'; 

$has_main_menu = (has_nav_menu('top_nav')) ? 'true' : 'false';

if($headerColorScheme == 'dark') { $userSetBG = '#1f1f1f'; }    

$userSetSideWidgetArea = $sideWidgetArea;

if($has_main_menu == 'true' && $mobile_fixed == '1') $sideWidgetArea = '1';

if($headerFormat == 'centered-menu-under-logo') $fullWidthHeader = 'false';

?>
</head>

主要是主题标题是自定义的。我在该代码中没有看到任何问题。请指导我如何解决这个问题。

Here is the w3c validation

1 个答案:

答案 0 :(得分:1)

你的html中有一些注释错误。

首先在这里:(这是更正后的代码)

<!-- [if IE 8]--> <link rel="stylesheet" type="text/css" href="https://www.accudock.com/wp-content/plugins/js_composer_salient/assets/css/vc-ie8.css" media="screen"> <!--[endif]--> <!-- BEGIN recaptcha, injected by plugin wp-recaptcha-integration --> <!-- END recaptcha --> <!-- WP Facebook Pixel Code - Main -->

接下来,从头部的<img>标记中删除<noscript>标记:

<noscript><img alt="" height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=638313929660068&ev=PageView&noscript=1" /></noscript>

这将解决杂散头标记错误。