【发布时间】:2020-09-11 12:48:24
【问题描述】:
如何将以下短代码正确添加到 WordPress 中的 functions.php?当我添加它时它可以工作,但它没有正确关闭并给我一个错误。
<?php echo do_shortcode( '[brb_collection id="297"]' ); ?>
我收到以下错误:
“由于文件 wp-content/themes/betheme-child/functions.php 的第 55 行出现错误,您的 PHP 代码更改已回滚。请修复并再次尝试保存。
语法错误,意外的'
这是我的functions.php
<?php
// // Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
function chld_thm_cfg_locale_css( $uri ){
if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
$uri = get_template_directory_uri() . '/rtl.css';
return $uri;
}
endif;
add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
// END ENQUEUE PARENT ACTION
/* Tillad at uploade fonts */
function wp39550_disable_real_mime_check( $data, $file, $filename, $mimes ) {
$wp_filetype = wp_check_filetype( $filename, $mimes );
$ext = $wp_filetype['ext'];
$type = $wp_filetype['type'];
$proper_filename = $data['proper_filename'];
return compact( 'ext', 'type', 'proper_filename' );
}
add_filter( 'wp_check_filetype_and_ext', 'wp39550_disable_real_mime_check', 10, 4 );
/* CF7 redirects */
add_action( 'wp_footer', 'redirect_cf7' );
function redirect_cf7() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '117' == event.detail.contactFormId ) { // Sends sumissions on form 947 to the first thank you page
location = 'https://example.com/thank-you/';
} else if ( '118' == event.detail.contactFormId ) { // Sends submissions on form 1070 to the second thank you page
location = 'https://example.com/thank-you/';
} else if ( '541' == event.detail.contactFormId ) { // Sends submissions on form 1070 to the second thank you page
location = 'https://example.com/da/tak/';
} else if ( '542' == event.detail.contactFormId ) { // Sends submissions on form 1070 to the second thank you page
location = 'https://example.com/da/tak/';
}
}, false );
</script>
<?php
}
/* Google reivew widget */
<?php echo do_shortcode( '[brb_collection id="297"]' ); ?>
【问题讨论】:
-
您可能需要在此处显示 wp-content/themes/betheme-child/functions.php 中的代码。
-
似乎您的 functions.php 以意外字符结尾。你可以添加你的functions.php文件的结束/最后一个视图行吗?
-
非常不清楚您要在这里做什么。您是在尝试在页面上使用简码“brb_collection”,还是尝试添加过滤掉简码的功能?
-
我正在尝试从插件中添加短代码,因为它会在我网站的所有页面上显示 Google 评论小部件。用我所有的functions.php代码编辑了帖子,看看哪里出了问题。
标签: javascript php html wordpress