permalinks - Custom optional parameter in page URL
I'm losing my mind, so I do hope I can get some help here..
What I'm trying to do is to create an optional parameter for search page, just for the sake of SEO
For example, there are the options:
/search/ (category = null)
/search/contracts (category = contracts)
/search/.../ (category = whatever this parameter $1 is)
While search is a page
I've tried adding htaccess rewrite rule, and wordpress simply redirected 301 without passing the parameter. Then I tried with add_rewrite_endpoint, nothing worked whatsoever and I've tried with
function wpd_add_query_vars( $qvars ) {
$qvars[] = 'category';
return $qvars;
}
add_filter( 'query_vars', 'wpd_add_query_vars' );
add_rewrite_rule(
'^search/([^/]+)/?',
'index.php?post_id=806&category=$matches[1]',
'top'
);
add_rewrite_tag('%category%', '([^&]+)');
flush_rewrite_rules();
Do note I tried just about every permutation, also tried plugins, nothing worked. It was either a 404 or the $wp_query->query_vars did not include the parameter.
Thanks in advance..
- 外媒称谷歌正筹划自主开发安卓手机
- .NET开源:微软"云为先"战略的全面铺开
- 三问凡客“毁三观”
- 成本高、厂商疑 微软Surface面临十大风险
- 又是一场数码盛宴 台北电脑展展品预热
- Windows8是备胎?解析微软移动市场战略
- python - How to solve this TensorflowTensorboard compatibility problem? - Stack Overflow
- powershell - Windows AutoPilot - Set Auto Login - Stack Overflow
- The uid generator is giving negative value(-8201645565344219221) and using this implementation DefaultUidGenerator.java to gener
- apache beam - Unable to Write processed Data to Parquet - Stack Overflow
- unity game engine - After commit to git, all gameobjects loose their assets - Stack Overflow
- rust - How Can I Efficiently Render an Emulator Framebuffer in an Iced Widget at 60 FPS? - Stack Overflow
- installation - Upgrading to Inno Setup v6 - SignTool=sha1 no longer works - Stack Overflow
- typescript - Pinia types not working in nuxt3 with auto imports - Stack Overflow
- Odoo: BOM Update Not Removing Deleted Items from RFQ in Purchase Orders - Stack Overflow
- typescript - angular signal is not recomputing - Stack Overflow
- javascript - <function name> error: FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been