Last active
August 29, 2015 14:12
-
-
Save marushu/8938754cb54041b75fb1 to your computer and use it in GitHub Desktop.
投稿を抽出する際、タイトルが同じ投稿がある場合、同名の投稿の中でIDが一番新しいもののみを出す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$get_posts_arr = array(); | |
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; | |
$args = array( | |
'post_type' => 'post', | |
'numberposts' => 10000, | |
'posts_per_page' => 100, | |
'paged' => $paged, | |
); | |
$another_way_retrieve_posts = get_posts( $args ); | |
foreach( $another_way_retrieve_posts as $another_way_retrieve_post ) { | |
if( $another_way_retrieve_post ) { | |
$get_posts_arr[ "$another_way_retrieve_post->ID" ] = esc_html( strip_tags( $another_way_retrieve_post->post_title ) ); | |
} | |
} | |
$get_posts_arr = array_unique( $get_posts_arr ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment