I scrapped that snippet and instead used the Show Future Posts on Single Posts plugin, which worked fine. I tried pulling out the code from the plugin to drop in my functions file (credited, of course) just to avoid excess plugins, but it broke the universe, so I’m just going to stick with it in the plugin. ?? In case that’s help for you or anyone else.
Re: pretty permalinks
I think your “old method” (as noted in your file) may be the better route because with just the post_name, it leaves off any other segments associated with the post. I probably won’t be the only person to run into that issue.
That said, I found a snippet that works really well and changes the URL for future posts to a nice, tidy permalink like normal:
// Nice URL for Future Posts
// // post, page post type
add_filter( 'post_link', 'future_permalink', 10, 3 );
// custom post types
add_filter( 'post_type_link', 'future_permalink', 10, 4 );
function future_permalink( $permalink, $post, $leavename, $sample = false ) {
/* for filter recursion (infinite loop) */
static $recursing = false;
if ( empty( $post->ID ) ) {
return $permalink;
}
if ( !$recursing ) {
if ( isset( $post->post_status ) && ( 'future' === $post->post_status ) ) {
// set the post status to publish to get the 'publish' permalink
$post->post_status = 'publish';
$recursing = true;
return get_permalink( $post, $leavename ) ;
}
}
$recursing = false;
return $permalink;
}
Found here!
It doesn’t seem to have broken anything. Everything is functioning as intended. So SUCCESS! ??
The only thing that would be perfection right now is if I could show the taxonomy or category the post is filed in. But I understand that might be more complex. Thank you for all your help with this. I’ll be on the lookout if you happen to figure out that last bit.
-
This reply was modified 6 years, 8 months ago by
Joelle. Reason: added link to plugin
-
This reply was modified 6 years, 8 months ago by
Joelle.