StudioPress Community Forums
  StudioPress Community Forums > Forums > General Discussion
For help and support, access to your downloads, or to manage your account please log into My StudioPress.

These forums have been set to read-only so you can browse the existing topics for any questions you may have.

For general discussion on WordPress, CSS and design (NOT for support) visit the new Community Forums.
 
 
Thread Tools Display Modes
  #1  
Old 10-13-2012, 01:10 PM
theimageworks theimageworks is offline
Registered User
Pro Plus Member
 
Join Date: Oct 2011
Posts: 69
Default Specific H1 dependent on post category

What I would like to do is the following....

If the page is a "post" from the "portfolio" category then I want to override the H1 so its <h1>Portfolio</h1> and not the name of the post.

Likewise if the "post" is from the "blog" category then I want to override the H1 so its <h1>Blog</h1> and not the name of the post.

I'm guessing the answer is to use hooks but could you point me in the right direction please.

Something off the top of my head:

PHP Code:

<?php
if (is_category'portfolio' )){ ?>

remove_action( 'genesis_post_content', 'genesis_post_title' );
add_action('genesis_post_title','customtitle', 0) ;


function customtitle($customtitle) {

    $customtitle = '<h1>Portfolio</h1>';

    return $customtitle;




<?php
} elseif (is_category'blog' ) )){ ?>


remove_action( 'genesis_post_content', 'genesis_post_title' );
add_action('genesis_post_title','customtitle', 0) ;


function customtitle($customtitle) {

    $customtitle = '<h1>Blog</h1>';

    return $customtitle;


<?php
?>
I've had a go and probably made a right mess, so some guidance would be appreciated please. ):
  #2  
Old 10-14-2012, 10:47 AM
NicktheGeek's Avatar
NicktheGeek NicktheGeek is offline
Forum Manager
 
Join Date: Feb 2010
Posts: 62,650
Default

Which theme are you using? Where did you try and add this code?
__________________
Nick "Fred and/or George Weasley" Croft
Designs by Nick the Geek
@Nick_theGeek on Twitter

Make web design easier, get FireBug for FireFox

Want to learn more about Genesis? Check out my Genesis Explained Series

  #3  
Old 10-15-2012, 02:20 AM
theimageworks theimageworks is offline
Registered User
Pro Plus Member
 
Join Date: Oct 2011
Posts: 69
Default

I'm using the metric theme and I tried adding this in both the functions file and in the simple hooks "genesis_before_content Hook" area.

I don't even know if the code I typed is correct...
  #4  
Old 10-15-2012, 09:02 AM
NicktheGeek's Avatar
NicktheGeek NicktheGeek is offline
Forum Manager
 
Join Date: Feb 2010
Posts: 62,650
Default

no, the code isn't right I just needed some info so I can help make it right.

In the functions.php file you don't need <?php ?> so just use
PHP Code:

remove_action
'genesis_post_title''genesis_do_post_title' ); 
add_action'genesis_post_title''child_customtitle' ); 


function 
child_customtitle() { 

    if ( 
is_single() && in_category'portfolio' ) ) 
        echo 
'<h1>Portfolio</h1>'
    elseif ( 
is_single() && in_category'blog' ) )  
        echo 
'<h1>Blog</h1>'
    else
        
genesis_do_post_title();


__________________
Nick "Fred and/or George Weasley" Croft
Designs by Nick the Geek
@Nick_theGeek on Twitter

Make web design easier, get FireBug for FireFox

Want to learn more about Genesis? Check out my Genesis Explained Series

 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:13 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.