Jump to content
Sign in to follow this  
szool

making a custom header on posts page

Recommended Posts

szool
http://citizenmediagroup.com/category/news/ If you click the "News" menu item on the main nav, it displays my "news" category. I'd like to have my own header come up at the top of the screen before the posts appear, with a little picture of a newspaper, etc. How can I do that?

Share this post


Link to post
Share on other sites
wp101

Hey Herman, I might be wrong, but I don't believe it is possible to show a pic like you require for a seperate category via the theme itself. However, usually in Wordpress we can create a new category page for each individual category by following the procedure outlined here: http://codex.wordpress.org/Category_Templates). Pageline theme contents is created programmatically so there is a little more to it than the above steps, however. I have just quickly tried this myself on the theme and it works fine as far as I can see. If you feel comfortable in doing some (light) coding, you can follow my quick implementation below. i. create a file perhaps called "category-news.php" and save it to the root of the theme. ii. open index.php and copy paste what's in there to the new file. iii. open template_posts.php (library subfolder) and copy the contents; paste what you copy to the new file in place of this line:

include(THEME_LIB.'/template_posts.php');
iv. then place your newspaper picture with whatever styling you want to give it, just above where it says:
<?php include (THEME_LIB . '/_posts.php'); ?>
v. You'd have to also add/remove some of the php start and end tags at the top and bottom of the page so that you switch from php/html properly. That ought to do it for you. If you want some reference, here are the contents of my final file: --- <?php /* WhiteHousePro Copyright © 2008-2010 Andrew Powers, PageLines.com (hello AT pagelines DOT com) PHP code licensed under the terms of GPL. */ get_header(); ?> <?php if(is_page_template('page-fullwidth.php') || is_page_template('page-fullhighlight.php') || is_page_template('page-carousel-full.php')) $full_width_page = true; else $full_width_page = false; if(is_page_template('page-carousel.php') || is_page_template('page-carousel-full.php')) $carousel_page = true; else $carousel_page = false; if(VPRO && (is_page_template('page-feature.php') || is_page_template('page-feature-page.php') || (is_home() && pagelines('featureblog')))) $featureslide_template = true; else $featureslide_template = false; if(VPRO && (is_page_template('page-feature.php') || m_pagelines('featureboxes', $post->ID))) $fboxes_template = true; else $fboxes_template = false; ?> <?php if($featureslide_template) include(PAGELINES_PRO . '/template_feature.php'); ?> <?php if($carousel_page) include(PAGELINES_PRO.'/template_carousel.php');?> <?php if(!is_404()) include(THEME_LIB.'/_subhead.php');?> <?php if(is_page_template('page-fullhighlight.php') || is_page_template('page-highlight.php') ) include (PAGELINES_PRO . '/template_highlight.php'); ?> <div id="contentcontainer" class="content fix"> <div id="contentborder"> <?php if($fboxes_template) include(PAGELINES_PRO . '/template_fboxes.php');?> <?php if(!is_page_template('page-feature.php')):?> <div id="maincontent" <?php if($full_width_page):?>class="fullwidth"<?php endif;?> > <div>****NEW STUFF HERE****</div> <?php include (THEME_LIB . '/_posts.php'); ?> </div> <?php if(!$full_width_page) get_sidebar();?> <?php include (THEME_LIB . '/_contentfooter.php'); ?> <?php endif;?> <div class="clear"></div> </div> </div> <?php get_footer(); ?> --- You could try copying my above code into a file called category-news.php and ftp to your theme root. Make any alterations you want where it says:
<div>****NEW STUFF HERE****</div>

. You could style the div by assigning it an id - i.e <div id="xyz"> and appending the css for xyz in the custom css area of the theme. Hope that helps!

Share this post


Link to post
Share on other sites
szool

can I use this plugin? It requires a code entry in "category.php" or "archive.php" but the StationPro theme does not have either of those. http://www.heinzcooler.de/category-header-content/ Shows HTML at your category pages. After activating please insert <?= get_chc() ?> in your category template or if you doesnt have one in your archive template. For HTML at your tag pages insert <?= get_thc() ?>

Share this post


Link to post
Share on other sites
szool

Installation First you have to insert <?= get_chc() ?> in your category template, to find at category.php in your template directory. If there is no category.php (like in Kubrick) look out for archive.php and column <?php /* If this is a category archive */ if (is_category()) { ?> <h2 class="pagetitle"><?php printf(__('Archive for the ???%s??™ Category', 'kubrick'), single_cat_title('', false)); ?></h2> and insert <?= get_chc() ?> directly after this, or wherever you want.

Share this post


Link to post
Share on other sites
szool

looking at your instructions above... I don't understand how I activate the new "category-news.php" file so that when I click on "News" it uses that file?

Share this post


Link to post
Share on other sites
cmunns

Are you trying to replace the main header with a custom one for just this one page. If so we can do that fairly easily without creating a new page template.

Share this post


Link to post
Share on other sites
szool

No I want each category page to have it's own...

Share this post


Link to post
Share on other sites
wp101

Herman, following my instructions, you wouldn't need to explicitly activate anything. WP would handle it automatically. Try it? Just copy paste all my code into a file named as above. If it doesn't work as expected, simply delete the file.

Share this post


Link to post
Share on other sites
szool

yes I did that and it worked flawlessly! Most excellent! I was even able to insert an image! The only thing I don't understand is how to edit the formatting of the text. I'm not up on CSS... I used HTML to add the text and the image to the header, and it took everything except for the font size. It ignores my attempts to change the font size.

Share this post


Link to post
Share on other sites
bryan-hadaway

I'm no longer seeing a custom/different header for the news category in order to edit? Thanks, Bryan

Share this post


Link to post
Share on other sites
cmunns

The first step is to add a class to this portion of the code: `

****NEW STUFF HERE****
` so it looks something like this: `
****NEW STUFF HERE****
` You could even replace it so it looks like this: `

****NEW STUFF HERE****

` Then you'll add this to your style sheet or to your custom CSS area `.cat_head {font-size:22px;padding:10px 0;}` or whatever size you want

Share this post


Link to post
Share on other sites
szool

awesome.... it really works! check it out... click on "News" on the main menu: http://citizenmediagroup.com Now my question is.... how to make that header persist when then click on one of the news articles?

Share this post


Link to post
Share on other sites
bryan-hadaway

Wonderful to hear. Thanks, Bryan

Share this post


Link to post
Share on other sites
szool

Well there is one more thing. I have the header working for the category... but when you click on a post in that category, the header disappears. I'd like to to remain on the screen while you are viewing the posts within that category.

Share this post


Link to post
Share on other sites
bryan-hadaway

I believe you'd also need to make the edit to: Appearance > Editor > _posts.php Please make sure to back everything up before making this edit so you can always revert back if it doesn't work out. Thanks, Bryan

Share this post


Link to post
Share on other sites
szool

ah ok. I am looking at _posts.php now.... do you know where I would insert the code?

Share this post


Link to post
Share on other sites
bryan-hadaway

Unfortunately no, hopefully one of the PageLines theme developers comes along and is able to answer that question. Thanks, Bryan

Share this post


Link to post
Share on other sites
szool

ok let me know what they say. As an extension of this.... can we get a custom header when they click the monthly archives links at the footer? Say they click on "June 2010" so at the top of the screen before the posts it will have my text "Monthly Archives for June 2010" exactly like it does now if they click on "News" or "Schedule" from the main menu http://citizenmediagroup.com

Share this post


Link to post
Share on other sites
cmunns

You'll need to go and copy that code you added before so that it is inserted on the top of the _posts.php file with a conditional, for example: ` <?php if(is_category() || is_single()):?> **YOUR CODE FROM BEFORE** <?php endif;?> `

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  

×