I have a few custom post types on my website. One of these is a front page slider. I add some text, images, links and as soon as I publish the CPT appears as a slide and I’m a happy camper. The problem is when I need to preview the slide before it is live. I can preview that specific CPT post via the post preview button, but obviously I see the actual slide and not how the slide looks in that slider or gallery or archive.
I’m looking for a solution to preview the Drafts in an archive.
Any help will be much appreciated.
The
get_posts
method ofWP_Query
is what does the heavy lifting as far as getting the posts to display. Before it does anything, however, there’s a hook calledpre_get_posts
that you can hook into. The hooked function will receive a reference (pointer) to the current query object. So you can change the query vars to be whatever you’d like.So…
You’ll probably have to change your
post_type
fromslider
to whatever you slider CPT is named.As a plugin: https://gist.github.com/1343219