How to create a front end user profile with a friendly permalink and a 404 trigger

I believe the solution here would be as simple as you’ve generally described it. Assuming conveniently that $wp_query->query_vars[‘user’] contains the username and not its ID: if ( array_key_exists( ‘user’, $wp_query->query_vars ) ) { if ( username_exists( $wp_query->query_vars[‘user’] ) ) { include( TEMPLATEPATH . ‘/user-profile.php’ ); } else { include( TEMPLATEPATH . ‘/404.php’ ); } exit; … Read more

How to achieve my custom post url structure?

I have created the custom URL using the function: add_rewrite_rule($regex, $redirect, $after). add_rewrite_rule( ‘^my-page/(.+)/?$’, ‘index.php?pagename=my-page&url=$matches[1]’, ‘top’ ); You can write your own custom rewrite rule and redirect to appropriate page: https://codex.wordpress.org/Rewrite_API/add_rewrite_rule

Permalinks: display just one kind of wp category in the posts url

Two things need to be done. First, make your posts URL is different using the post_link filter. function _20170117_post_link( $url, $post, $leavename ) { if( in_category( ‘news’, $post) ) { $url = get_site_url() . ‘/news/’ . $post->post_name ; } return $url; } add_filter( ‘post_link’, ‘_20170117_post_link’, 10, 3 ); Second, make the rewrite rule for this: … Read more