Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我如何修改下面的代码段,以便如果页面具有父页面,则父标题/链接将显示在wordpress中_Php_Wordpress_Woocommerce - Fatal编程技术网

Php 我如何修改下面的代码段,以便如果页面具有父页面,则父标题/链接将显示在wordpress中

Php 我如何修改下面的代码段,以便如果页面具有父页面,则父标题/链接将显示在wordpress中,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,您可以使用$post->post\U parent检查父项,并使用以下方法获取标题: 或: 谢谢乔治,我明白了: 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; } add_fi

您可以使用$post->post\U parent检查父项,并使用以下方法获取标题:

或:


谢谢乔治,我明白了:
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;

}
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;

}
$args['title'] = get_the_title($post->post_parent ?: NULL);