对于我的头文件, 我在下面有以下代码。但是, 如果我关闭Woocommerce插件, 则会收到很多错误代码(请参见下文)
<ul class="site-header-cart menu">
<li>
<?php storefront_cart_link(); ?>
</li>
<li>
<?php the_widget( 'WC_Widget_Cart', 'title=' ); ?>
</li>
</ul>
/////////////////
这与这一行有关-这是否需要成为if语句。我已经尝试修复了几个小时, 但没有成功。我只是对PHP有基本了解的新手
当打开” woocommerce”时, 页面看起来没有错误, 但是控制台镶边中明显出现了一些jquery错误-因此尝试修复错误代码
https://tiltrak.com/webdev/
致命错误:未捕获错误:调用/home/mpex/tiltrak.com/public/webdev/wp-content/themes/storefront-child/header.php中未定义的功能storefront_cart_link():43堆栈跟踪:#0 / home / mpex / tiltrak.com / public / webdev / wp-includes / template.php(688):require_once()#1 /home/mpex/tiltrak.com/public/webdev/wp-includes/template.php(647): load_template(‘/ home / mpex / tilt …’, true)#2 /home/mpex/tiltrak.com/public/webdev/wp-includes/general-template.php(41):locate_template(Array, true) #3 /home/mpex/tiltrak.com/public/webdev/wp-content/themes/storefront-child/page.php(5):get_header()#4 /home/mpex/tiltrak.com/public/webdev/ wp-includes / template-loader.php(74):include(‘/ home / mpex / tilt …’)#5 /home/mpex/tiltrak.com/public/webdev/wp-blog-header.php( 19):require_once(‘/ home / mpex / tilt …’)#6 /home/mpex/tiltrak.com/public/webdev/index.php(17):require(‘/ home / mpex / tilt .. 。)第7行{main}在第43行的/home/mpex/tiltrak.com/public/webdev/wp-content/themes/storefront-child/header.php中抛出
任何帮助, 不胜感激
<?php
/**
* The header for our theme.
*
* Displays all of the <head> section and everything up till <div id="content">
*
* @package storefront
*/
?><!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2.0">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<style>
@import url('https://fonts.googleapis.com/css?family=Montserrat');
</style>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<!-- Start of Top Navigation -->
<div class="container-fluid grey-nav-bar">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-5 col-lg-5">
<?php wp_nav_menu( array( 'theme_location' => 'customer-menu' ) ); ?>
</div>
<div class="col-xs-12 col-sm-12 col-md-5 col-lg-5">
<?php wp_nav_menu( array( 'theme_location' => 'place-adverts' ) ); ?>
</div>
<div class="col-xs-12 col-sm-12 col-md-2 col-lg-2">
<ul class="site-header-cart menu">
<li>
<?php storefront_cart_link(); ?>
</li>
<li>
<?php the_widget( 'WC_Widget_Cart', 'title=' ); ?>
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- End of Top Navigation -->
<!-- Start of Top Logo and Product Search -->
<div class="container-fluid">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="main-logo"><a href="https://tiltrak.com/webdev/home"><img src="https://tiltrak.com/webdev/wp-content/uploads/2018/11/tiltrak-automotive-marketplace-buy-sell-cars-classic-cars-motorcycles-vans-commercial-vehicles-autojumble-motor-factors-accessories-shop-uk.jpg" alt="tiltrak automotive marketplace buy sell cars classic cars motorcycles vans commercial vehicles autojumble motor factors accessories shop uk"></a> </div>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="search-tophold">
<div class="site-search">
<?php if ( function_exists( 'aws_get_search_form' ) ) { aws_get_search_form(); } ?>
</div>
<div class="contact-header">Tel: <a href="tel:01925394434">01925 394 434</a> • Email: <a href="mailto:hello@tiltraks.com">hello@tiltrak.com</a></div>
</div>
</div>
</div>
</div>
</div>
<!-- End of Top Logo and Product Search -->
<?php do_action( 'storefront_before_site' ); ?>
<?php do_action( 'storefront_before_header' ); ?>
<header id="masthead" class="site-header" role="banner" style="<?php storefront_header_styles(); ?>">
<?php
/**
* Functions hooked into storefront_header action
*
* @hooked storefront_header_container - 0
* @hooked storefront_skip_links - 5
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_header_container_close - 41
* @hooked storefront_primary_navigation_wrapper - 42
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
* @hooked storefront_primary_navigation_wrapper_close - 68
*/
do_action( 'storefront_header' ); ?>
</header><!-- #masthead -->
<?php
/**
* Functions hooked in to storefront_before_content
*
* @hooked storefront_header_widget_region - 10
* @hooked woocommerce_breadcrumb - 10
*/
do_action( 'storefront_before_content' ); ?>
<div id="content" class="site-content" tabindex="-1">
<div class="col-full">
<?php
do_action( 'storefront_content_top' );
#1
假设此模板是自定义的, 并且此行为是由于该模板希望始终安装WooCommerce而引起的, 则只需在发布的header.php文件中删除对未定义函数的引用即可:
<div class="col-xs-12 col-sm-12 col-md-2 col-lg-2">
<ul class="site-header-cart menu">
<li>
<?php //storefront_cart_link(); ?>
</li>
<li>
<?php the_widget( 'WC_Widget_Cart', 'title=' ); ?>
</li>
</ul>
</div>
在上面, 我已注释掉storefront_cart_link();。函数调用。我不知道删除函数调用的含义。尝试过此方法后最好对其进行测试, 看看是否有帮助!
评论前必须登录!
注册