Blog Post Categories and Sub Categories
I am having some problem with my blog post.
I have create two main categories 1. Jobseekers and 2. Employers --- I have created sub categories under each --- just fine.
I have also created two new blog.php files for each so they can have their own look and feel
blog-jobseekers.php
blog-employers.php
I have also created two new category file from my archive.php file
category-jobseekers.php
category-employers.php
I have also created multiple single.php files
single-jobseekers.php
single-employers.php
single-default.php
I inserted this piece of code in the new single.php file
<?php
/**
* Tests if any of a post's assigned categories are descendants of target categories
*
* @param int|array $cats The target categories. Integer ID or array of integer IDs
* @param int|object $_post The post. Omit to test the current post in the Loop or main query
* @return bool True if at least 1 of the post's categories is a descendant of any of the target categories
* @see get_term_by() You can get a category by name or slug, then pass ID to this function
* @uses get_term_children() Passes $cats
* @uses in_category() Passes $_post (can be empty)
* @version 2.7
* @link
http://codex.wordpress.org/Function_...ndant_category
*/
if ( ! function_exists( 'post_is_in_descendant_category' ) ) {
function post_is_in_descendant_category( $cats, $_post = null ) {
foreach ( (array) $cats as $cat ) {
// get_term_children() accepts integer ID only
$descendants = get_term_children( (int) $cat, 'category' );
if ( $descendants && in_category( $descendants, $_post ) )
return true;
}
return false;
}
}
?>
<?php
$post = $wp_query->post;
if (in_category( 'jobseekers' ) || post_is_in_descendant_category( get_term_by( 'jobseekers' ) )) {
include(TEMPLATEPATH.'/single-jobseekers.php');
} elseif (in_category( 'radiology' ) || post_is_in_descendant_category( get_term_by( 'radiology' ) )) {
include(TEMPLATEPATH.'/single-radiology.php');
} elseif (in_category( 'nursing' ) || post_is_in_descendant_category( get_term_by( 'nursing' ) )) {
include(TEMPLATEPATH.'/single-nursing.php');
} else {
include(TEMPLATEPATH.'/single-default.php');
}
?>
After setting all this up I am able to go directly to the jobseekers blog homepage with all the post pertaining to only the jobseeker and also the employers.
It list all the post with excerpts -- you can even query each sub categories.
But when you click on the link for each post you get a blank post with no content ---
What gives.
Sam