How to: Make future custom posts display with pretty permalinks
-
Been stumbling around the issue of giving single future custom posts pretty permalinks. I’ve (finally) found a solution that others might find useful as well.
First, it turns out that the “broken” (i.e. ugly) permalinks for future/scheduled posts is intentional for privacy reasons (see trac #30910).
Fortunately, you can still pretty permalink to custom post types that are future/scheduled using get_post_permalink() instead of the_permalink() and setting the $sample parameter to true. (More at the get_post_permalink() codex page.) So:
echo get_post_permalink( '','','true');
Note that get_post_permalink() retrieves the permalink as get_permalink() does rather than displaying it as the_permalink() does.
FYI, I’m using the Future plugin and
'post_status' => array( 'publish', 'future' ),
in my custom post type wp_query() args.
For the future custom post type archive by month I’m using the following URL structure: https://mydomain.com/2016/03/?post_type=listing&future=all (where ‘listing’ is my custom post type slug). Note that ‘all’ here pulls both current and future posts so if it’s the middle of the month you’re looking at you’ll see past and upcoming posts.
- The topic ‘How to: Make future custom posts display with pretty permalinks’ is closed to new replies.