• Maybe I am just going crazy here, but isn’t there a simple tag that will allow me to do this:

    If I am on a page, it will render like:

    sitename: page title

    If I am on a post, it will render like:

    sitename: post title

    The wp_title(); tag isn’t working and the the_title(); tag isn’t working. What am I missing here?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Try <?php bloginfo('name'); ?><?php wp_title(); ?>

    Thread Starter patrickw

    (@patrickw)

    Each page renders the title of the window:

    sitename

    Each post renders the title of the page:

    sitename ? Post Name

    Any other ideas?

    Can you give us a link so we can see the problem for ourselves?

    That piece of code I have implemented on a huge amount of WP themes, so I can’t imagine why it isn’t behaving correctly for you.

    Also; what version of WP do you have running?

    Thread Starter patrickw

    (@patrickw)

    Alright, after some more testing, it seems to work on pages using the default template. The two pages I was testing were using a template. One being the home.php and then the whole:

    <?php query_posts('cat=-0'); //gets all posts
    load_template( TEMPLATEPATH . '/index.php'); //loads index
    ?>

    I am going to play with the other pages, see what’s going on.

    To answer your questions, I can’t give out the url just yet and I am running the latest.. 2.0.2

    Thread Starter patrickw

    (@patrickw)

    Alright, why it’s working now, I have no idea, but I went back and rewrote all the templates for the pages, the home.php and the header.php.

    Anyway, here is what my new title tag looks like:

    <? bloginfo('name'); if(is_home()) { echo ': home'; } elseif(is_single()) { echo ': journal:'; echo strtolower(wp_title('', 0)); } else { echo ':'; echo strtolower(wp_title('', 0)); } ?>

    For all of you out there who aren’t coders, this is what it does:

    This goes in the title tag.
    1) Prints the name of the blog
    2) If it is the homepage, it appends ‘: home’ to the end of the title tag, so now the home page looks like: sitename: home.
    3) If it is not the home page, but it is a single blog post (see: is_single()), it will append ‘: journal:’ and the post name to the end of the title after the blog name has printed so it looks like: sitename: journal: post title. The strtolower also takes the title of the post and converts it to all lowercase, just for aesthetics.
    4) If the parameters dont match any of the above circumstances, then, just return the title of the page after it has been converted into lowercase.

    Anyway, thanks for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Template Tag Issues’ is closed to new replies.