Skip to content

Instantly share code, notes, and snippets.

Live long and may the source be with you

Stefan Pejcic stefanpejcic

Live long and may the source be with you
View GitHub Profile
stefanpejcic / single.php
Last active Jul 19, 2019
Different single post template based on category
View single.php
define(SINGLE_PATH, TEMPLATEPATH . '/single');
add_filter('single_template', 'my_single_template');
function my_single_template($single) {
global $wp_query, $post;
foreach((array)get_the_category() as $cat) :
if(file_exists(SINGLE_PATH . '/single-cat-' . $cat->slug . '.php'))
View gist:f76bb9ecbdf263ddbb832ac474b2448b
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'; }
View gist:f40a09a009801982c303699499de7a77
/* * Template Name: Featured Article
* Template Post Type: post, page, product
get_header(); ?>
View gist:d98d13c10a8ec6f3333723f9a3b4227b
== Screenshots ==
1. This is the description for the first screenshot
2. This is the description for the second screenshot
3. This is the description for the third screenshot
View gist:21161c5c29717d73d518d588dd799103
View gist:2c31e3edc51b45ce583c440acb7925a7
[ Description for the first screenshot]
[ Description for the second screenshot]
[ Description for the third screenshot]
View gist:9d217dc0e8c2ceeb7030fd0763f7823d
svn propset svn:mime-type image/gif *.gif
svn propset svn:mime-type image/jpeg *.jpg
svn propset svn:mime-type image/png *.png
View gist:1113608fbc0f0d3a45b5e44c73f65aac
svn propset svn:mime-type image/jpeg screenshot-1.jpg
svn propset svn:mime-type image/jpeg screenshot-2.jpg
svn propset svn:mime-type image/jpeg screenshot-3.jpg