【发布时间】:2015-03-06 17:49:40
【问题描述】:
我需要在 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;
}
【问题讨论】:
-
检查 html 源代码,浏览器可能将其解释得很奇怪。您可以在它之前放置一个 pre 标签并在之后退出以帮助使其在浏览器中可见