获取标题中显示的错误。
/**************************/
/* Facebook Support */
function get_fbimage() {
global $post;
if ( !is_single() ){
return '';
}
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '', '' );
$fbimage = null;
if ( has_post_thumbnail($post->ID) ) {
$fbimage = $src[0];
} else {
global $post, $posts;
$fbimage = '';
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i',
$post->post_content, $matches);
if(!empty($matches[1]))
$fbimage = $matches [1] [0];
}
if(empty($fbimage)) {
$fbimage = get_the_post_thumbnail($post->ID);
}
return $fbimage;
}
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
function remove_add_to_cart_buttons() {
if( is_product_category() || is_shop()) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
}
/**************************/
该页面显示错误位于第158行:
...
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i',
...
出了什么问题?
答案 0 :(得分:0)
当您在正则表达式中转义单引号时,请使用双反斜杠:
$output = preg_match_all('/<img.+src=[\\'"]([^\\'"]+)[\\'"].*>/i',