在functions.php中的Wordpress var_dump

acc*_*man 6 php wordpress

我需要在WP中的自定义函数过滤器中执行var_dump但是,结果显示在哪里?代码正在运行,因为我可以看到搜索结果结构与代码存在时的区别

    add_filter('relevanssi_hits_filter', 'products_first');
function products_first($hits) {
    $types = array();

    $types['section1'] = array();
    $types['section2'] = array();
    $types['section3'] = array();
    $types['section4'] = array();

    // Split the post types in array $types
    if (!empty($hits)) {
        foreach ($hits[0] as $hit) {
            array_push($types_1[$hit->post_type], $hit);
        }
    }

    // Merge back to $hits in the desired order
    var_dump($types);
    $hits[0] = array_merge($types['section1'], $types['section2'], $types['section3'], $types['section4']);
    return $hits;
}
Run Code Online (Sandbox Code Playgroud)

tax*_*ala 10

尝试在var_dump之后立即杀死流,这通常可以帮助我更容易地调试:

var_dump($types);
die("products_first_ends");
Run Code Online (Sandbox Code Playgroud)

这样,如果你的var_dump之后的东西在var转储之上渲染它就不会被它覆盖.