add_filter('avf_title_args', 'fix_page_title', 10, 1);
function fix_page_title($args) {
$args['title'] = get_the_title();
$args['link'] = get_permalink();
return $args;
}
You can check for a parent using $post->post_parent
and get the title using get_the_title()
:
add_filter('avf_title_args', 'fix_page_title', 10, 1);
function fix_page_title($args) {
global $post;
if($post->post_parent){
$args['title'] = get_the_title();
} else {
$args['title'] = get_the_title( $post->post_parent );
}
$args['link'] = get_permalink();
return $args;
}
Or:
$args['title'] = get_the_title($post->post_parent ?: NULL);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.