I have a Problem i want to make a speceal layout for all my video posts. i want to remove the header for that reason and load another css file.
the strange thing is. the css loads just fine and i use the same function "check_if_videopost()" but it not works for the header remove. when i uncomment it then it works fine.
am i doing something wrong or is this maybe not possible to do in the "init" action?
please help
i want to uncomment and the if and else in the remove_header() function i dont want to remove it from every my entire site.
/**
* 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_Reference/in_category#Testing_if_a_post_is_in_a_descendant_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;
}
}
// parent category id of all video post $parentcat_of_all_video_post = IN HERE;
function check_if_videopost() {
$parentcat = 73;
if (is_single() && post_is_in_descendant_category($parentcat)):
return true;
else:
return false;
endif;
}
function remove_header() {
//if (check_if_videopost()):
remove_action('thematic_header','thematic_brandingopen',1);
remove_action('thematic_header','thematic_blogtitle',3);
remove_action('thematic_header','thematic_blogdescription',5);
remove_action('thematic_header','thematic_brandingclose',7);
remove_action('thematic_header','thematic_access',9);
//endif;
}
add_action('init', 'remove_header');
// load css for single posts who have are in child categories of the carent category xyz
// give videoparentcat id of your video parent category
function childtheme_css() {
if (check_if_videopost()): ?>
<link rel="stylesheet" type="text/css" href="<?php echo
bloginfo('stylesheet_directory') ?>/video.css" />
<?php endif;
}
add_action('wp_head', 'childtheme_css');
`