【发布时间】:2018-08-04 21:01:41
【问题描述】:
使用 Wordpress 中的 css/html 内置编辑器,我在 functions.php 文件中添加了一些代码,但发生了一些错误,每次打开网站时都会出现以下错误:
ParseError thrown
syntax error, unexpected '<', expecting end of file
我使用文件管理器访问了主题的functions.php文件并将其替换为主题的原始文件,代码中没有出现错误,但是打开网站时仍然存在相同的错误。有什么问题?提前致谢。
编辑:这是functions.php 文件内容的一部分。我添加的代码在最后,后来我删除了它,但错误仍然存在。
<?php
/**
* Buzz Store functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Buzz_Store
*/
if ( ! function_exists( 'buzzstore_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress
features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features,
such
* as indicating support for post thumbnails.
*/
function buzzstore_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on Buzz Store, use a find and replace
* to change 'buzzstore' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'buzzstore', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
// WooCommerce Plugins Support
add_theme_support( 'woocommerce' );
// Set up the WordPress Gallery Lightbox
add_theme_support('wc-product-gallery-lightbox');
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for custom logo.
*/
add_theme_support( 'custom-logo', array(
'width' => 190,
'height' => 60,
'flex-width' => true,
'flex-height' => true,
'header-text' => array( '.site-title', '.site-description' ),
) );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
add_image_size('buzzstore-banner-image', 1350, 485, true); // banner
add_image_size('buzzstore-news-image', 370, 285, true); // Home Blog
add_image_size('buzzstore-news-details-image', 850, 385, true); // Details Blog
add_image_size('buzzstore-cat-image', 275, 370, true);
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'topmenu' => esc_html__( 'Top Menu', 'buzzstore' ),
'primary' => esc_html__( 'Primary', 'buzzstore' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
function buzzstore_customize_partial_blogname() {
bloginfo( 'name' );
}
function buzzstore_customize_partial_blogdescription() {
bloginfo( 'description' );
}
【问题讨论】:
-
“可能出了什么问题?” - 某处可能存在解析错误。对于您提供的少量信息,任何人都不可能提供帮助。当您收到该错误时,它还应该说明错误发生在哪个文件和哪一行。如果您发布该代码,我们可能会提供帮助。请阅读:How to create a Minimal, Complete, and Verifiable example 和 How do I ask a good question?
-
非常感谢。不幸的是,该错误没有说明错误的位置。无论如何,我现在要插入 functions.php 文件。任何帮助将不胜感激。
-
检查 Web 服务器错误日志以查看是否获得更多信息,例如堆栈跟踪。无论哪种方式,如果我们看不到它,我们就无法知道您的代码有什么问题。顺便说一句,您如何使用 WP 中的 html/css 编辑器向
functions.php添加代码? -
好吧,除非你设法缩小发生在哪里,否则这个问题将无法回答。
-
@DouaAli,我想帮你缩小问题的范围。我们正在寻找可能出现在任何地方的语法错误(正如 Magnus 已经提到的)。首先不要编辑任何东西,并确保您发布到 StackOverflow 的证据与您的实际代码库保持同步。乍一看,您的 functions.php 中实际上存在语法错误,但由于它被截断,我们真的无法保证。你能把你的functions.php的完整副本上传到pastebin吗?