Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin tommcfarlin/00-get-stories.php Secret
Created Jul 19, 2017

Embed
What would you like to do?
[WordPress] How to Display Recent Custom Post Types (Excluding the Current Post)
<?php
use WP_Query;
function get_stories() {
return new WP_Query([
'posts_per_page' => 5,
'post_type' => 'story',
]);
}
<?php
use WP_Query;
function get_stories() {
return new WP_Query([
'post__not_in' => [ get_the_ID() ],
'posts_per_page' => 5,
'post_type' => 'story',
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.