我是新来的,我不确定如何正确地提出这个问题。我的目标是在wordpress中更改我的徽标的href,在wordpress中没有简单的设置所以我决定改变代码本身。我得到的错误是"解析错误:语法错误,意外'<'在/home/gtacontr/public_html/mississaugacardetailing.ca/blog/wp-content/themes/publisherly/header.php第38行" 。下面是我的代码,有人可以告诉我为什么我收到此错误,我该如何解决?
<?php
/**
* The header for our theme
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package Publisherly
*/
?><!DOCTYPE html>
<html class="no-js" <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'publisherly' ); ?></a> <!-- add this reference in code -->
<header id="masthead" class="site-header" role="banner">
<div class="header-wrapper">
<div class="site-branding">
<a href="http://www.mississaugacardetailing.ca">
//<?php
// Display the Custom Logo
<img width="2000" height="666" src="http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo.png" class="custom-logo" alt="" itemprop="logo" srcset="http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo.png 2000w, http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo-300x100.png 300w, http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo-768x256.png 768w, http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo-1024x341.png 1024w" sizes="(max-width: 2000px) 100vw, 2000px"></a>
/* if ( has_custom_logo() ) {
the_custom_logo();
} else {
if ( is_front_page() && is_home() ) : ?>
</a>
<h1 class="site-title"><a href="www.mississaugacardetailing.ca"> rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?>
<p class="site-title"><a href="www.mississaugacardetailing.ca"> rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php endif;
}
?> */
</div><!-- .site-branding -->
<?php if ( has_nav_menu( 'primary' ) ) : ?>
<a id="menu-toggle" class="menu-toggle" href="#"><!-- <i class="fa fa-bars"></i>--> <?php _e( 'Menu', 'publisherly' ); ?></a>
<div id="site-header-menu" class="site-header-menu">
<?php if ( has_nav_menu( 'primary' ) ) : ?>
<nav id="site-navigation" class="main-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Primary Menu', 'publisherly' ); ?>">
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_class' => 'primary-menu',
) );
?>
</nav><!-- .main-navigation -->
<?php endif; ?>
</div><!-- .site-header-menu -->
<?php endif; ?>
</div><!-- /header-wrapper -->
</header><!-- .site-header -->
答案 0 :(得分:0)
你应该这样评论
<!--?php // Display the Custom Logo -->
<img width="2000" height="666" src="..." sizes="(max-width: 2000px) 100vw, 2000px"></a>
<!-- if ( has_custom_logo() ) {
the_custom_logo();
} else {
if ( is_front_page() && is_home() ) : ?>
</a>
<h1 class="site-title"><a href="www.mississaugacardetailing.ca"> rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<!--?php else : ?>
<p class="site-title"><a href="www.mississaugacardetailing.ca"> rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php endif;
}
?-->
如果您发现我刚刚更改了代码,那么<?php
变为<!--?php
而?>
变为?-->
。这只是一个个人的prefrenace,因为它帮助我记住事物的位置,如果你保持PHP标记完好无损,它们将作为PHP工作,但输出将在注释内。我对HTML也这样做,例如:
<!-- form id="myfrom" action="" >
</form -->
注意这就是说如果这是一个实时网站,我可能只留下PHP,因为你不希望代码在页面的源代码中被替换。
这是一个沙箱,显示您的错误sandbox
干杯。
答案 1 :(得分:0)
您需要在anchor()标记内更改“”标记附近,并确保需要对其进行注释,或者如果不需要则需要删除此标记。并在图像标记后删除锚标记。请看下面的代码。
<a href="http://www.mississaugacardetailing.ca">
<!--?php
// Display the Custom Logo
?-->
<img width="2000" height="666" src="http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo.png" class="custom-logo" alt="" itemprop="logo" srcset="http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo.png 2000w, http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo-300x100.png 300w, http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo-768x256.png 768w, http://www.mississaugacardetailing.ca/blog/wp-content/uploads/2017/06/cardetailinglogo-1024x341.png 1024w" sizes="(max-width: 2000px) 100vw, 2000px">
<!--?php /* if ( has_custom_logo() ) {
the_custom_logo();
} else {
if ( is_front_page() && is_home() ) : ?-->
</a>