Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Filter Site Title to Add CSS Class (in Genesis child theme) WordPress

  • SOLVED

Hi all,

If you're a Genesis member, you can read the entire thread about what I'm doing [[LINK href="http://www.studiopress.com/support/showthread.php?t=58948"]]here[[/LINK]].

In short, I am adding a CSS class name provided by the Fonts for Web API to various places in my Genesis child theme and custom WP menus (via the Custom CSS Styles input). This is working beautifully so far and I have managed to change the font on page titles, post titles, widget titles (using a custom menu widget), and the nav items in the main navigation.

This is the class name:

fontsforwebfontid801


The one and only thing I still need to add this CSS class to is the main site title. I don't know if there's a Genesis-specific filter for this or if it's WP.

I am looking for filter function code to achieve adding this CSS class name to the main site title.

For reference, this is the filter I'm using for post title output that works great.

//Filter Post Title to Add Font Class
add_filter('genesis_post_title_output', 'fontforweb_post_title_output');
function fontforweb_post_title_output( $title ) {
return sprintf( '<h2 class="fontsforwebfontid801">%s</h2>', apply_filters( 'genesis_post_title_text', get_the_title() ) );
}

Answers (1)

2011-04-19

Utkarsh Kukreti answers:

Try this:

add_filter('genesis_seo_title', 'fontforweb_genesis_seo_title', 10, 3);
function fontforweb_genesis_seo_title($title, $inside, $wrap) {
return sprintf('<%s class="fontsforwebfontid801" id="title">%s</%s>', $wrap, $inside, $wrap);
}


Adam W. Warner comments:

Thanks, tried it with missing argument error:



Warning: Missing argument 2 for fontforweb_genesis_seo_title() in /home/mybody/public_html/demo.adamwwarner.com/wp-content/themes/crystal/functions.php on line 17

Warning: Missing argument 3 for fontforweb_genesis_seo_title() in /home/mybody/public_html/demo.adamwwarner.com/wp-content/themes/crystal/functions.php on line 17
< class="fontsforwebfontid801" id="title">


Utkarsh Kukreti comments:

Please try the updated code.