Define orderby in url

adding this in the functions.php file works. Just remember to re-save your permalinks & empty the cache a few times to see the changes. add_action( ‘init’, ‘wpse13483_init’ ); function wpse13483_init() { add_rewrite_rule( ‘category/(.+?)/orderby/([^/]+)?/?$’, ‘index.php?category_name=$matches[1]&orderby=$matches[2]&order=asc’, ‘top’ ); add_rewrite_rule( ‘category/(.+?)/orderby/([^/]+)/order/([^/]+)?/?$’, ‘index.php?category_name=$matches[1]&orderby=$matches[2]&order=$matches[3]’, ‘top’ ); // with pagination; add_rewrite_rule( ‘category/(.+?)/orderby/([^/]+)/order/([^/]+)/page/([0-9]{1,})?/?$’, ‘index.php?category_name=$matches[1]&orderby=$matches[2]&order=$matches[3]&paged=$matches[4]’, ‘top’ ); }

Customising rewrite rules for CPT single post URL to work as paged URL

Ok, so I got it working more or less correctly, although there is still a small problem left, please read on.. Here is what I’ve got: in fucntions.php: Rewrite rules add_action(‘init’, ‘my_rewrite_add_rewrites’); function my_rewrite_add_rewrites(){ add_rewrite_rule( ‘^services/([^/]+)/?$’, ‘index.php?post_type=service&order=ASC&orderby=menu_order’, ‘top’ ); add_rewrite_rule( ‘^services/([^/]+)/page/?([0-9]{1,})/?$’, ‘index.php?post_type=service&paged=$matches[2]&order=ASC&orderby=menu_order’, ‘top’ ); } Redirect rule add_action(“template_redirect”, ‘my_template_redirect’); function my_template_redirect(){ global $wp_query; // if … Read more

Permalink Rewrite for Custom Taxonomy

There are a few parts to making this work. First, we register the taxonomy: function wpa69163_register_txonomy() { register_taxonomy(‘board’, ‘post’, array( ‘labels’ => array( ‘name’ => _x( ‘Boards’, ‘taxonomy general name’ ), ), ‘rewrite’ => array( ‘slug’ => ‘board’, ‘with_front’ => false ) )); } add_action( ‘init’, ‘wpa69163_register_txonomy’, 0 ); Next, we have to add a … Read more

Custom user profile URLs

Create an endpoint for EP_ROOT named profile. In your callback handler use get_user_by( ‘slug’, get_query_var( ‘profile’ ) ) to find the user data. Create a template file profile.php and use locate_template( ‘profile.php’, TRUE ) to load it. In your template show the user data.

URL Rewrite doesn’t work for nested pages

I have found my answer while searching. Thanks to this answer of @Milo: https://wordpress.stackexchange.com/a/50775/23214 pagename must include the full parent/child path. So, I had to change index.php?pagename=page-b… to index.php?pagename=page-a/page-b…. Changed it and works ok. Here is the Full code: add_filter( ‘query_vars’, ‘wpse26388_query_vars’ ); function wpse26388_query_vars( $query_vars ){ $query_vars[] = ‘var1’; $query_vars[] = ‘var2’; $query_vars[] = … Read more