简体   繁体   English

如何在函数中添加/关闭简码。WordPress 中的 php

[英]How to add/close a shortcode to functions.php in WordPress

How would I go about adding the following shortcode properly to functions.php in WordPress?我将如何 go 将以下短代码正确添加到函数中。WordPress 中的 php? When I add it works but it isn't closed properly and gives me an error.当我添加它时它可以工作,但它没有正确关闭并给我一个错误。

 <?php echo do_shortcode( '[brb_collection id="297"]' ); ?>

I am getting the following error:我收到以下错误:

"Your PHP code changes were rolled back due to an error on line 55 of file wp-content/themes/betheme-child/functions.php. Please fix and try saving again. “由于文件 wp-content/themes/betheme-child/functions.php 第 55 行的错误,您的 PHP 代码更改已回滚。请修复并再次尝试保存。

syntax error, unexpected '<', expecting end of file"语法错误,意外的 '<',期待文件结尾"

Here is my functions.php这是我的函数。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"]' ); ?>

You're reopening php, while already in a php section您正在重新打开 php,同时已经在 php 部分

Just remove the php opening tag right before your last echo只需在最后一个回声之前删除 php 开始标签

Or close the previous php section before the comment /* Google reivew widget */或者在评论前关闭前面的 php 部分 /* Google reivew widget */

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM