Skip to content

Instantly share code, notes, and snippets.

View stefanpejcic's full-sized avatar
:octocat:
Live long and may the source be with you

Stefan Pejcic stefanpejcic

:octocat:
Live long and may the source be with you
View GitHub Profile
@stefanpejcic
stefanpejcic / single.php
Last active July 19, 2019 17:44
Different single post template based on category
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'))
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'; }
<?php
/* * Template Name: Featured Article
* Template Post Type: post, page, product
*/
get_header(); ?>
[Link Text](http://example.com/)
<a href="http://example.com/">Link Text</a>
== 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
/plugin-directory/assets/screenshot-1.png
/plugin-directory/assets/screenshot-2.jpg
/plugin-directory/assets/screenshot-3.png
[http://example.com/images/screenshot.png Description for the first screenshot]
[http://example.com/images/another-one.png Description for the second screenshot]
[http://example.com/images/and-another.jpg Description for the third screenshot]
svn propset svn:mime-type image/gif *.gif
svn propset svn:mime-type image/jpeg *.jpg
svn propset svn:mime-type image/png *.png
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