Skip to content

Commit

Permalink
fix rewrite for hierarchical posts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefelipe committed Nov 30, 2023
1 parent 325c7da commit 33029c1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Settings/Rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,16 @@ public static function postType(
bool $year = false,
array $extra_params = []
) {
static::archive(
static::single(
$post_type,
$path,
$paged,
$year,
$extra_params
);
static::single(
static::archive(
$post_type,
$path,
$paged,
$year,
$extra_params
);
}
Expand Down Expand Up @@ -310,9 +310,10 @@ public static function single(
}

// rewrite
$match_regex = \is_post_type_hierarchical($post_type) ? '(.+?)' : '([^/]+)';

\add_rewrite_rule(
$_path . '([^/]+)/?$',
$_path . $match_regex . '/?$',
'index.php?' . $post_type . '=$matches[1]'
. $params_string,
$order
Expand Down

0 comments on commit 33029c1

Please sign in to comment.