Skip to content

Instantly share code, notes, and snippets.

@rabdano
Created April 20, 2011 18:13
Show Gist options
  • Select an option

  • Save rabdano/932187 to your computer and use it in GitHub Desktop.

Select an option

Save rabdano/932187 to your computer and use it in GitHub Desktop.
Получить массив постов WordPress отсортированых в обратном порядке по ID
<?php
$args = array(
'post_type' => 'тип поста',
'posts_per_page' => -1,
'orderby' => 'id',
'order' => 'DESC'
);
$posts = get_posts( $args );
foreach ( $posts as $post ) {
setup_postdata( $post );
$title = get_the_title( $post->ID );
$id = $post->ID;
echo "ID = $id\nTitle = $title";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment