Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanpejcic/f76bb9ecbdf263ddbb832ac474b2448b to your computer and use it in GitHub Desktop.
Save stefanpejcic/f76bb9ecbdf263ddbb832ac474b2448b to your computer and use it in GitHub Desktop.
define(SINGLE_PATH, TEMPLATEPATH . '/single');
add_filter('single_template', 'my_single_author_template');
function my_single_author_template($single) {
global $wp_query, $post; $curauth = get_userdata($wp_query->post->post_author);
if(file_exists(SINGLE_PATH . '/single-author-' . $curauth->user_nicename . '.php')) return SINGLE_PATH . '/single-author-' . $curauth->user_nicename . '.php'; elseif(file_exists(SINGLE_PATH . '/single-author-' . $curauth->ID . '.php')) return SINGLE_PATH . '/single-author-' . $curauth->ID . '.php'; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment