Author Meta in Author URL Link

This is just an example / idea and I haven’t tested if this really works. But I think it could be something along these lines. function custom_author_base() { global $wp_rewrite; global $wp_query; // On author pages you get current author for example with $wp_query $curauth = $wp_query->get_queried_object(); // Get the required data $country = get_user_meta($curauth->ID, … Read more

Custom permalink question

What you need is to register your own Rewrite Rule. To do it you should use add_rewrite_rule function. function my_custom_external_rewrite_rule() { add_rewrite_rule(‘^post-type-name/([^/]+)/?’, ‘index.php?page_id=<PAGE_ID>&external_page_name=$matches[1]’, ‘top’); } add_action( ‘init’, ‘my_custom_external_rewrite_rule’ ); And you’ll have to register your custom query variable (using query_vars hook): function my_custom_external_query_var( $query_vars ) { $query_vars[] = ‘external_page_name’; return $query_vars; } add_filter( ‘query_vars’, ‘my_custom_external_query_var’ … Read more

Changing author slug for a custom role without using plugin

You can use add_permastruct() (with ep_mask set to EP_AUTHORS) to add the proper rewrite rules, and the author_link filter to set the proper author URL: add_action( ‘init’, function(){ add_permastruct( ‘%author_trip_vendor%’, ‘operator/%author%’, [ ‘ep_mask’ => EP_AUTHORS, ] ); } ); add_filter( ‘author_link’, function( $link, $author_id, $author_nicename ){ if ( user_can( $author_id, ‘trip_vendor’ ) ) { $link … Read more