[wp-hackers] Problem with custom title tags

Austin Matzko if.website at gmail.com
Wed Feb 18 20:27:55 GMT 2009


On Wed, Feb 18, 2009 at 1:32 PM, Kim Parsell <kparsell-wp at kpdesign.net> wrote:
> The first one that I am having problems with is:
>
> <?php if (is_front_page()) { ?><?php bloginfo('name'); ?> - <?php echo
> bloginfo ('description'); } ?>
>
> This returns <title>Blog Name - Service, Support, Solutions Blog Name
> </title>. The blog name is being repeated after the description (is this a
> bug or intended behavior?).

The problem is that you're using a series of if statements instead of
if...else.  So is_front_page() is true, and then is_page() is true,
printing the name again.

> The other one I am having problems with is:
>
> <?php if (is_single()) { ?><?php bloginfo('name'); ?> | <?php
> single_cat_title(); ?>: <?php the_title(); } ?>
>
> This code returns <title>Blog Name | : Who We Are</title> - note that the
> Category title (single_cat_title) is missing.

This won't work because single_cat_title() only works when it's a
category that's being queried.  If is_single() is true, then it's a
single post being queried.

Try wp_get_post_categories(get_the_ID()) to get an array of post IDs.

For future reference, a great place for support requests is the
WordPress support forum:  http://wordpress.org/support/
The wp-hackers list is supposed to be mainly for development issues,
more or less.


More information about the wp-hackers mailing list