-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
Hello, if enable option Forum Prefix, topic page return 404 error. Problem in "function add_post_types_rewrite" bbp_get_topic_slug() return "forums/topic" but add_permastruct get_option( '_bbp_topic_slug', 'topic' ) return "topic":
rewrite rule - forums/forum(.+?)forums/topic/(.+?)/?$
permastruct - forums/forum/%forumnames%/topic/%forumnames%/
if change bbp_get_topic_slug() to get_option( '_bbp_topic_slug', 'topic' ) all works
public static function add_post_types_rewrite($postType, $args)
{
$topic_slug = get_option( '_bbp_topic_slug', 'topic' );
switch ($postType) {
case bbp_get_topic_post_type():
// Paged topic Rule
add_rewrite_rule(
bbp_get_forum_slug().'(.+?)'.$topic_slug.'/(.+?)/'.bbp_get_paged_slug().'/([0-9]{1,})/?$',
'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType.'&paged=$matches[3]',
'top'
);
// Edit topic rule
add_rewrite_rule(
bbp_get_forum_slug().'(.+?)'.$topic_slug.'/(.+?)/edit/?$',
'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType.'&'.bbp_get_edit_rewrite_id().'=1',
'top'
);
// View topic rule
add_rewrite_rule(
bbp_get_forum_slug().'(.+?)'.$topic_slug.'/(.+?)/?$',
'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType,
'top'
);
add_permastruct($postType, bbp_get_forum_slug()."%forumnames%".$topic_slug."/%postname%/", $args->rewrite);
static::flush_rewrite_rules_if_needed();
break;
}
}