Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.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注意:第3442行的taxonomy.PHP和第1279行的category-template.PHP中的数组到字符串转换_Php_Wordpress_Loops_While Loop - Fatal编程技术网

PHP注意:第3442行的taxonomy.PHP和第1279行的category-template.PHP中的数组到字符串转换

PHP注意:第3442行的taxonomy.PHP和第1279行的category-template.PHP中的数组到字符串转换,php,wordpress,loops,while-loop,Php,Wordpress,Loops,While Loop,我在我的Wordpress循环中得到了这两个PHP通知,我已经进行了全面的研究,但我不知道如何解决这个问题。脚本按预期工作,但页面上到处都是通知 注意:第3442行的\wp includes\taxonomy.php中的数组到字符串转换 注意:第1279行的\wp includes\category-template.php中的数组到字符串转换 我在互联网上搜索过,我认为这可能是导致问题的代码,但我不知道是什么破坏了它,无论我做什么尝试,我似乎都无法修复它。请有人帮我解决这个问题,并向我解释这个

我在我的Wordpress循环中得到了这两个PHP通知,我已经进行了全面的研究,但我不知道如何解决这个问题。脚本按预期工作,但页面上到处都是通知

注意:第3442行的\wp includes\taxonomy.php中的数组到字符串转换

注意:第1279行的\wp includes\category-template.php中的数组到字符串转换

我在互联网上搜索过,我认为这可能是导致问题的代码,但我不知道是什么破坏了它,无论我做什么尝试,我似乎都无法修复它。请有人帮我解决这个问题,并向我解释这个问题

     <?php

        if ( $the_query->have_posts() ) : 
$i=1;
            // Start the Loop 
            while ( $the_query->have_posts() ) : $the_query->the_post(); 
          ?>
                <?php 
$terms = get_the_terms( $post->ID, array('date-category', 'programme-category') );
if ( $terms && ! is_wp_error( $terms ) ) :

    $catTag = array();
    foreach ( $terms as $term ) {
        $catTag[] = $term->slug;
    }

    $catTag = implode(" ", $catTag );
    ?>

来自文档:

检索附加到文章的分类的术语

参数

  • $post(int |)(必需)post ID或对象
  • $taxonomy(字符串)(必填)分类名称
要求第二个参数
$taxonomy
字符串,但您正在传递一个数组

$terms = get_the_terms( $post->ID, array('date-category', 'programme-category') );
这就是为什么您会看到“数组到字符串转换”错误消息

您只能向函数传递一个分类法,而不是两个。例如:

$terms = get_the_terms( $post->ID, 'date-category' );
或:

$terms = get_the_terms( $post->ID, 'programme-category' );