I have this function:
function wpse_210493_apply_advertising_position( &$posts, $return = false ) {
$ad_posts = array();
$content_posts = array_filter(
$posts,
function ( $post ) {
$position = get_post_meta( $post->ID, 'rw_adversiting_position', true );
if ( empty( $position ) ) {
return true;
}
$ad_posts[ intval( $position ) ] = $post;
return false;
} );
$content_posts = array_values( $content_posts );
ksort( $ad_posts );
echo "sdfksfkjshdfsdf";
foreach ( $ad_posts as $position => $ad ) {
array_splice( $content_posts, $position, 0, $ad );
}
if ( $return ) {
return $content_posts;
} else {
$posts = $content_posts;
}
}
I need to debug $ad_posts
after the ksort()
but output is not going to browser. I did test with the echo
you see there and that text also is not going to browser as output. How do I debug the values properly?