Skip to content

Instantly share code, notes, and snippets.

@raulillana
Last active August 29, 2015 14:04
Show Gist options
  • Save raulillana/bcf58137a59686f9bf41 to your computer and use it in GitHub Desktop.
Save raulillana/bcf58137a59686f9bf41 to your computer and use it in GitHub Desktop.
Filter WP post_category Array in get_posts() loop.
<?php
$posts = get_posts();
foreach( $posts as $post ):
// filter post_category array
if( is_array($post->post_category) )
foreach( $post->post_category as $k => $v )
$post->post_category = $v;
endforeach;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment