- Deprecated: Function get_magic_quotes_gpc() is deprecated in /var/html/dev/wp/wp-includes/formatting.php on line 4371Deprecated: Function get_magic_quotes_gpc() is deprecated in /var/html/dev/wp/wp-includes/formatting.php on line 4371Notice: Trying to get property 'comment_author_email' of non-object in /var/html/dev/wp/wp-content/plugins/fv-gravatar-cache/fv-gravatar-cache.php on line 236
kjkjava
ParticipantWarning: Cannot modify header information - headers already sent by (output started at /var/html/dev/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php:340) in /var/html/dev/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220Hello,
Thanks for the recent update to Pinboard! It’s nice to know it’s still being maintained. I had just finished adding Featured Image support to a custom post type in my child theme, by hooking into init. It wasn’t fun, but good to see that was updated in the recent release.
Anyway, I’m having some issues regarding page titles (in the tag). I’m not sure whether this has something to do with it, but my blog is not the home page. Most pages simply have the title of the page (e.g. “About Me”). My custom post type archive page has the website title after the page, which is what I’m going for (e.g. “Testamonials | Awesome Website”). Then, the blog itself has “Blog” in front and the blog tagline after it (e.g. “BlogAwesome Website | Just another WordPress site…”). The inconsistancies must be coming from title filters, since the same header file is used regardless.
Here is the title filter code in functions.php:
if ( ! function_exists( 'pinboard_doc_title' ) ) :
/**
* Output the tag
*
* @since Pinboard 1.0
*/
function pinboard_doc_title( $doc_title ) {
global $page, $paged;
$doc_title = str_replace( '»', '', $doc_title );
$site_description = get_bloginfo( 'description', 'display' );
$separator = '#124';
if ( is_singular() ) {
if( is_front_page() )
$doc_title .= get_the_title();
if ( $paged >= 2 || $page >= 2 )
$doc_title .= ', ' . __( 'Page', 'pinboard' ) . ' ' . max( $paged, $page );
} else {
if( ! is_home() )
$doc_title .= ' &' . $separator . '; ';
$doc_title .= get_bloginfo( 'name' );
if ( $paged >= 2 || $page >= 2 )
$doc_title .= ', ' . __( 'Page', 'pinboard' ) . ' ' . max( $paged, $page );
}
if ( ( is_home() ) && $site_description )
$doc_title .= ' &' . $separator . '; ' . $site_description;
return $doc_title;
}
endif;I’m guessing there might be a bug in the nesting of the if statements. If you take a look at the WordPress Template Hierarchy, is_front_page() should never be true if is_singular() is true.
Thanks for any advice on the proper modifications to make.
-Kyle
AdvertismentDeprecated: Function get_magic_quotes_gpc() is deprecated in /var/html/dev/wp/wp-includes/formatting.php on line 4371Deprecated: Function get_magic_quotes_gpc() is deprecated in /var/html/dev/wp/wp-includes/formatting.php on line 4371Notice: Trying to get property 'comment_author_email' of non-object in /var/html/dev/wp/wp-content/plugins/fv-gravatar-cache/fv-gravatar-cache.php on line 236kjkjava
ParticipantWarning: Cannot modify header information - headers already sent by (output started at /var/html/dev/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php:340) in /var/html/dev/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220Forgive the misspellings: *Testimonials *inconsistencies. Oops.
Deprecated: Function get_magic_quotes_gpc() is deprecated in /var/html/dev/wp/wp-includes/formatting.php on line 4371Deprecated: Function get_magic_quotes_gpc() is deprecated in /var/html/dev/wp/wp-includes/formatting.php on line 4371Notice: Trying to get property 'comment_author_email' of non-object in /var/html/dev/wp/wp-content/plugins/fv-gravatar-cache/fv-gravatar-cache.php on line 236kjkjava
ParticipantWarning: Cannot modify header information - headers already sent by (output started at /var/html/dev/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php:340) in /var/html/dev/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220Alright, here is the solution that seems to work for me. Let me know if I missed something or if there is something that can be improved.
Take a look at the code here: http://pastebin.com/J0F7QkXn (with syntax highlighting and the original) or below.
function pinboard_doc_title( $doc_title ) {
global $page, $paged;
$doc_title = str_replace( '» ', '', $doc_title ); // Notice the added space after »
$site_description = get_bloginfo( 'description', 'display' );
$separator = '|'; // | ... I brought the & and ; into the $separator stringif ( is_front_page() ) {
// Display the title of the website, regardless of the page title
$doc_title = get_bloginfo( 'name' );
if ( $site_description )
// And the site description if there is one, though this may look like the rest of the pages, only flipped around the |
$doc_title .= ' ' . $separator . ' ' . $site_description;
} else {
// For every other page, use "Page | Site Name" (and page number, if appropriate)
if ( $paged >= 2 || $page >= 2 )
$doc_title .= ', ' . __( 'Page', 'pinboard' ) . ' ' . max( $paged, $page );
$doc_title .= ' ' . $separator . ' ' . get_bloginfo('name');
}
return $doc_title;
}
-Kyle
Deprecated: Function get_magic_quotes_gpc() is deprecated in /var/html/dev/wp/wp-includes/formatting.php on line 4371Deprecated: Function get_magic_quotes_gpc() is deprecated in /var/html/dev/wp/wp-includes/formatting.php on line 4371Notice: Trying to get property 'comment_author_email' of non-object in /var/html/dev/wp/wp-content/plugins/fv-gravatar-cache/fv-gravatar-cache.php on line 236Daniel Tara
KeymasterWarning: Cannot modify header information - headers already sent by (output started at /var/html/dev/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php:340) in /var/html/dev/wp/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220Apparently there’s a bug with the title and static front pages. I recommend using a plugin like WordPress SEO by Yoast which overrides the title tag and has many options to configure it.
You must be logged in to reply to this topic.