无法在子主题(wordpress)中重新声明functions.php



我在child's functions.php中遇到错误。这里怎么了?

致命错误:无法在…中重新声明wpst_get_filter_title(((以前在…/functions.php中声明(/functions.php在线。。。

父函数.pp:

function wpst_get_filter_title() {
$title  = '';
$filter = '';
if ( isset( $_GET['filter'] ) ) {
$filter = $_GET['filter'];
} else {
$filter = xbox_get_field_value( 'wpst-options', 'show-videos-homepage' );
}
switch ( $filter ) {
case 'latest':
$title = esc_html__( 'Latest videos', 'wpst' );
break;
case 'most-viewed':
$title = esc_html__( 'Most viewed videos', 'wpst' );
break;
case 'longest':
$title = esc_html__( 'Longest videos', 'wpst' );
break;
case 'popular':
$title = esc_html__( 'Popular videos', 'wpst' );
break;
case 'random':
$title = esc_html__( 'Random videos', 'wpst' );
break;
default:
$title = esc_html__( 'Latest videos', 'wpst' );
break;
}
return $title;
}

儿童功能.pp:

if ( ! function_exists( 'wpst_get_filter_title' ) ) :
function wpst_get_filter_title() {
$title  = '';
$filter = '';
.
.
.
return $title;
}
endif;

您应该在子主题function.php文件中使用不同的函数名称,因为当您激活子主题时,它还会调用父主题文件,因此您不能两次使用函数名称,因此您应该将此wpst_get_filter_title((函数名称更改为子主题中的其他函数名称。

最新更新