我在下面的代码中收到T_Return语法错误..有什么想法吗?
function wp_support_create_feature( $post ) {
if ( defined('DOING_AUTOSAVE' && DOING_AUTOSAVE )
return $post;
if ( has_post_thumbnail( $post ) )
return $post
$first = get_children( array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'posts_per_page' => (int)1,
), ARRAY_A
);
set_post_thumbnail( $post->ID, $first[0]['ID'] );
}
add_action( 'save_post', 'wp_support_create_feature' );
答案 0 :(得分:4)
if ( defined('DOING_AUTOSAVE' && DOING_AUTOSAVE ))
^
你错过了一个右括号。
答案 1 :(得分:2)
function wp_support_create_feature( $post ) {
if ( defined('DOING_AUTOSAVE' && DOING_AUTOSAVE )) // closing parens
return $post;
if ( has_post_thumbnail( $post ) )
return $post; // semi-colon
$first = get_children( array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'posts_per_page' => (int)1,
), ARRAY_A
);
set_post_thumbnail( $post->ID, $first[0]['ID'] );
} add_action( 'save_post', 'wp_support_create_feature' );