admin管理员组文章数量:1410674
Following is example of what we are looking for. We're trying this in wordpress and we require all parameters as a variable
Example 1 : /?parent=abc
Need this :
Example 2 : /?parent=abc&sub1=abc&sub2=abc
Need this :
funtion.php code OR .htaccess rule any suggestion.
Thanks in advance
Following is example of what we are looking for. We're trying this in wordpress and we require all parameters as a variable
Example 1 : http://example/tno/?parent=abc
Need this : http://example/tno/abc
Example 2 : http://example/tno/?parent=abc&sub1=abc&sub2=abc
Need this : http://example/tno/abc/abc/abc
funtion.php code OR .htaccess rule any suggestion.
Thanks in advance
Share Improve this question edited Nov 20, 2019 at 16:07 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Nov 20, 2019 at 13:42 ViralViral 1033 bronze badges 4- to customise URL look that : wordpress.stackexchange/questions/352189/… – Kaperto Commented Nov 20, 2019 at 14:06
- How do you know it's not working? Please show us your code. – fuxia ♦ Commented Nov 20, 2019 at 14:17
- function archive_rewrite_rules() { add_rewrite_rule( '^/(.*)/(.*)/(.*)?$', 'index.php?post_type=client&parent=$matches[2]&sub1=$matches[3]&sub2=$matches[4]', 'top' ); } add_action( 'init', 'archive_rewrite_rules'); example/tno/… example/tno/helloenergy/zelf-aan-de-slag/mentaal – Viral Commented Nov 20, 2019 at 14:45
- @VipulGhetiya Please edit your question, and add that code. :) – fuxia ♦ Commented Nov 20, 2019 at 16:07
2 Answers
Reset to default 0Into wordpress function file add following code and check it.
add_filter('query_vars', function( $vars ){
$vars[] = 'parent';
return $vars;
});
function archive_rewrite_rules() {
add_rewrite_rule(
'^(.*)/(.*)/?$',
'index.php?post_type=client&name=$matches[1]&parent=$matches[2]',
'top'
);
add_rewrite_rule(
'^(.*)/?$',
'index.php?post_type=client&name=$matches[1]',
'top'
);
//flush_rewrite_rules(); // use only once
}
add_action( 'init', 'archive_rewrite_rules' );
Simply, go to Dashboard Setting > Permalink and change to "Post name" link type or you can use a plugin like enter link description here And for redirect you can use this plugin: enter link description here
本文标签: url rewritingWordPress URL redirect and replacequestion mark
版权声明:本文标题:url rewriting - WordPress URL redirect and replace ? question mark 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744982991a2635931.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论