Я новичок в разработке WordPress. Я определяю правило перезаписи (с тегом), подобное тому, что вы можете найти в примерах здесь и здесь.
Код: Выделить всё
$wp_rewrite->add_rewrite_tag('%filterx_location%', '([^&/]+)', 'filterx_location=');
$wp_rewrite->add_rule('property-location/(.+)$','index.php?post_type=property&filterx_location=$matches[1]', 'top');
Кажется, у меня отключилось электричество или что-то в этом роде. вроде чего-то простого, чего мне здесь не хватает, просто не могу понять :-/
Любая помощь очень ценится!
ОБНОВЛЕНИЕ
Что еще более странно, так это то, что когда я создаю правила перезаписи с помощью:
Код: Выделить всё
$wp_rewrite->add_rewrite_tag('%filterx_location%', '([^/]+)', 'filterx_location=');
$permalink_prefix = 'property-location';
$permalink_structure = '%filterx_location%/';
$rewrite_rules = $wp_rewrite->generate_rewrite_rules($permalink_prefix.'/'.$permalink_structure, EP_ALL, true, true, true, true, true);
Код: Выделить всё
property-location/([^/]+)/page/?([0-9]{1,})/?$ => index.php?filterx_location=$matches[1]&paged=$matches[2]&post_type=property
Код: Выделить всё
foreach($rewrite_rules as $regex => $redirect) {
if(strpos($redirect, 'attachment=') === false) {
//add the post_type to the rewrite rule
$redirect .= '&post_type=property';
}
//turn all of the $1, $2,... variables in the matching regex into $matches[] form
if(0 < preg_match_all('@\$([0-9])@', $redirect, $matches)) {
for($i = 0; $i < count($matches[0]); $i++) {
$redirect = str_replace($matches[0][$i], '$matches['.$matches[1][$i].']', $redirect);
}
}
//add the rewrite rule to wp_rewrite
$wp_rewrite->add_rule($regex, $redirect, 'top');
}
Подробнее здесь: https://stackoverflow.com/questions/182 ... write-rule
Мобильная версия