Jump to content
Sign in to follow this  
szool

cascading category headers

Recommended Posts

szool

In a former post we established how to create a custom header for each category page. There is an example of the finished work here, in the main menu click on "Special Events" http://citizenmediagroup.com Note the header at the top says "CMG Special Events" and there is currently one event that comes up in the list. But under that event when you click on "continue reading" the header disappears. How can we make the header remain there when we click on "continue reading"?

Share this post


Link to post
Share on other sites
cmunns

You will have to add the code as you did before to the _posts.php template file, but I think I may have given instructions for this in the previous posting. At the top of _posts.php you could add ` <?php if(is_single() && is_category('cat-name')):?> *** Custom Header Content *** <?php endif;?> ` I didn't test that but that's the jist of it where you put the name of the category where it says cat-name

Share this post


Link to post
Share on other sites
szool

_posts.php file below: <?php if(is_single() && is_category('cat-name')):?> *** Custom Header Content *** <?php endif;?> <?php if(is_search()):?> <div class="posts-news"> <h2 class="pagetitle posts-news-headline"><?php _e('Search Results For:',TDOMAIN);?> <span>"<?php the_search_query(); ?>"</span></h2> </div> <?php endif;?> <!-- The Loop --> <?php if (!is_404() && have_posts()) : while (have_posts()) : the_post(); // Start of the loop ?> <div class="postwrap fix"> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <?php if(is_single()):?> <div class="post-nav"> <span class="previous"><?php previous_post_link('%link') ?></span> <span class="next"><?php next_post_link('%link') ?></span></div> <?php endif;?> <?php if(!is_page()):?> <div class="copy fix"> <?php if(pl_show_thumb($post->ID)): ?> <div class="thumb left"> " rel="bookmark" title="<?php _e('Permanent Link To', TDOMAIN);?> <?php the_title_attribute();?>"> <?php the_post_thumbnail('thumbnail');?> </div> <?php elseif (get_post_meta($post->ID, 'thumb', true)): ?> <?php $postimageurl = get_post_meta($post->ID, 'thumb', true); ?> <div class="thumb left"> " rel="bookmark" title="<?php _e('Permanent Link To', TDOMAIN);?> <?php the_title_attribute();?>"> " alt="Post Pic" width="200" height="200" /> </div> <?php endif; ?> <div class="post-header fix <?php if(!pl_show_thumb($post->ID) && !get_post_meta($post->ID, 'thumb', true)) echo 'post-nothumb';?>" style="<?php if(pl_show_thumb($post->ID)){ $post_header_width = 555 - get_option('thumbnail_size_w'); echo 'width: '.$post_header_width.'px'; }?>"> <div class="post-title-section fix"> <div class="post-title fix"> <h2>" rel="bookmark" title="<?php _e('Permanent Link to',TDOMAIN);?> <?php the_title_attribute(); ?>"><?php the_title(); ?></h2> <div class="metabar"> <?php _e('On',TDOMAIN);?> <?php the_time(get_option('date_format')); ?>, <?php _e('in',TDOMAIN);?> <?php the_category(', ') ?>, <?php _e('by',TDOMAIN);?> <?php the_author(); ?> <!-- <?php edit_post_link(__('(Edit Post)', TDOMAIN), ' ', ' ');?> --> </div> </div> </div> <!--/post-title --> <?php if(pl_show_excerpt($post->ID)):?> <div class="post-excerpt"> <?php the_excerpt(); ?> </div> <?php endif; ?> </div> </div> <?php endif;?> <?php if(pl_show_content($post->ID) || is_category()):?> <div class="copy fix"> <?php if(pagelines('pagetitles') && is_page() || is_page_template('page-feature-blog.php')):?> <h1 class="pagetitle"><?php the_title(); ?></h1> <?php endif;?> <div class="textcontent"> <?php the_content(__('<p>Continue reading »</p>',TDOMAIN)); ?> <?php wp_link_pages(__('<p>Pages:', TDOMAIN), '</p>', __('number', TDOMAIN)); ?> <?php edit_post_link(__('Edit',TDOMAIN), '<p>', '</p>'); ?> </div> <div class="tags"> <?php the_tags(__('Tagged with: ', TDOMAIN),' • ',''); ?> </div> </div> <?php if(pagelines('authorinfo') && is_single()):?> <?php include(THEME_LIB.'/_authorinfo.php');?> <?php endif;?> <?php endif;?> <?php if(!is_page()) include(THEME_LIB.'/_post_footer.php');?> </div><!--post --> </div> <div class="clear"></div> <?php if(is_single() || is_page()):?> <?php include(THEME_LIB."/_contentsidebar.php");?> <?php if(!is_page() || (is_page() && pagelines('pagecomments', $post->ID))) include(THEME_LIB.'/_commentsform.php');?> <?php endif; endwhile; ?> <?php include(THEME_LIB.'/_pagination.php');?> <?php else : ?> <div class="postwrap fix"> <div class="hentry"> <div class="billboard"> <?php if(is_404()):?> <h2 class="center"><?php _e('Error 404 - Page Not Found',TDOMAIN);?></h2> <?php else:?> <h2 class="center"><?php _e('Nothing Found',TDOMAIN);?></h2> <?php endif;?> <p class="center"><?php _e('Sorry, what you are looking for isn't here.', TDOMAIN);?></p> <div class="center fix"><?php include (THEME_LIB . '/_searchform.php'); ?></div> </div> </div> </div> <?php endif; // end the loop ?>

Share this post


Link to post
Share on other sites
cmunns

You're supposed to put the name of that category where it says cat-name For example: is_category('cmg-special-events')

Share this post


Link to post
Share on other sites
szool

ok... so how would I make a different one for each category?

Share this post


Link to post
Share on other sites
bryan-hadaway

Please hold tight for further help from a developer. Thanks, Bryan

Share this post


Link to post
Share on other sites
cmunns

Instead of the code you have something like this would work to show the header for each different category depending on the category page. `

<?php $category = get_the_category(); echo $category[0]->cat_name;?>

`

Share this post


Link to post
Share on other sites
szool

I'm getting confused... can you explain what/where I need to enter to make the category header remain on the screen when you click on the posts within that category? I already have all the category headers created and they are working.... they just disappear once you click on a post within the category.

Share this post


Link to post
Share on other sites
Andrew

Maybe you aren't using the right conditionals... to make them work on single posts pages they will need to be within an `is_single()` conditional of some kind...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×