Custom Theme Template Wont Show After Adding Endpoint To Author Page
-
I am trying to get my custom gallery.php used when someone navigates to example.com/author/authorname/gallery.
Through a previous thread I was able to use the following code to rewrite the endpoint:
add_action('init', function() { global $wp_rewrite; add_rewrite_rule( $wp_rewrite->author_base . '/([^/]+)/gallery/?$', 'index.php?author_name=$matches[1]&_auth_gal=1', 'top' ); }); add_filter('query_vars', function($vars) { $vars[] = "_auth_gal"; return $vars; }); /** * tells whether we are in the author/^/gallery/ screen * use get_the_author_meta( 'ID' ) to get the author ID * * @return bool true|false */ function se_is_author_gallery() { return "1" == get_query_var('_auth_gal'); }
After ensuring I flushed the rewrite rules, and adding this code to the template theme file, I am still not able to get example.com/author/user/gallery to show up with the gallery.php template. Instead, it simply loads the same template as example.com/author/user/.
If you have any suggestions, advice, or feedback it would be greatly appreciated. Thank you so much.
- The topic ‘Custom Theme Template Wont Show After Adding Endpoint To Author Page’ is closed to new replies.