Skip to content

Instantly share code, notes, and snippets.

@leobaiano
Created March 29, 2017 16:35
Show Gist options
  • Save leobaiano/167229fedbb2271e97e5c3d2bf9766e4 to your computer and use it in GitHub Desktop.
Save leobaiano/167229fedbb2271e97e5c3d2bf9766e4 to your computer and use it in GitHub Desktop.
Template do single.php de acordo com a categoria do post acessado
<?php
global $post;
$categorias_do_post = get_the_category( $post->ID );
if ( file_exists( 'diretorio_com_templates/template-' . $categorias_do_post[0]->slug . '.php' ) {
require 'diretorio_com_templates/template-' . $categorias_do_post[0]->slug . '.php';
} else {
require 'diretorio_com_templates/template-default.php';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment