Skip to content

Commit 1f7d68b

Browse files
authored
Fix custom post type previews
1 parent 9dc2670 commit 1f7d68b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

wp-permastructure.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: WP Permastructure
44
Plugin URI: https://github.com/interconnectit/wp-permastructure
55
Description: Adds the ability to define permalink structures for any custom post type using rewrite tags.
6-
Version: 1.6.0
6+
Version: 1.6.1
77
Author: Robert O'Rourke
88
Author URI: http://interconnectit.com
99
License: GPLv2 or later
@@ -310,7 +310,10 @@ public function parse_permalinks( $post_link, $post, $leavename, $sample = false
310310

311311
$permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
312312

313-
if ( '' !== $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
313+
if (
314+
'' !== $permalink
315+
&& ! wp_force_plain_post_permalink( $post, $sample )
316+
) {
314317
$unixtime = strtotime( $post->post_date );
315318

316319
// add ability to use any taxonomies in post type permastruct
@@ -382,8 +385,9 @@ public function parse_permalinks( $post_link, $post, $leavename, $sample = false
382385
}
383386
$permalink = home_url( str_replace( $rewritecode, $rewritereplace, $permalink ) );
384387
$permalink = user_trailingslashit( $permalink, 'single' );
385-
} else { // if they're not using the fancy permalink option
386-
$permalink = home_url( '?p=' . $post->ID );
388+
} else {
389+
// If they're not using the fancy permalink option or it's forced to be plain.
390+
$permalink = $post_link;
387391
}
388392

389393
return $permalink;

0 commit comments

Comments
 (0)