我制作了我的第一个wordpress子主题,但它工作不正常。这是我的自定义函数。php编码:
// custom excerpt length
function themify_custom_excerpt_length( $length ) {
return 20;
}
add_filter( \'excerpt_length\', \'themify_custom_excerpt_length\', 999 );
//show logged-in menu and logged out menu
function my_wp_nav_menu_args( $args = ” ) {
if ($args[‘theme_location’] == ‘primary’) {
if( is_user_logged_in()) {
$args[‘menu’] = ‘logged-in’;
}else{
$args[‘menu’] = ‘logged-out’;
}
}
return $args;
}
add_filter( ‘wp_nav_menu_args’, ‘my_wp_nav_menu_args’ );
//Post database text on each post page within the loop
add_filter( \'the_content\', \'my_the_content_filter\', 20 );
function my_the_content_filter( $content ) {
if ( is_single() ){
$newcontent="here will be some data retrieved from the database, it will be beneath every post. I like it!";
$content .= $newcontent;
return $content;}
}
问题是我的摘录没有显示在主页上。我认为这与我上一个函数中的return$content部分有关。如果我删除我的孩子主题,摘录就会显示出来,所以我的编码一定有问题。有没有人知道该怎么做?