在functions.php中的Wordpress var_dump [英] Wordpress var_dump in functions.php
本文介绍了在functions.php中的Wordpress var_dump的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在 WP 的自定义函数过滤器中执行 var_dump,但是,结果显示在哪里?代码正在运行,因为我可以看到搜索结果结构与代码存在时和不存在时的差异
I need to do a var_dump in a custom function filter in WP but, where is the results shown? The code is working because I can see the search result structure difference from when the code is present and not
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;
}
推荐答案
尝试在 var_dump 之后立即终止流程,这通常可以帮助我更轻松地调试:
Try killing the flow right after the var_dump, that ussually helps me debug easier:
var_dump($types);
die("products_first_ends");
这样,如果 var_dump 之后的内容在 var dump 之上呈现,它就不会被它覆盖.
That way if something after your var_dump is rendering on top of the var dump it wont get covered by it.
这篇关于在functions.php中的Wordpress var_dump的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文