WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Static front page - title will not show as intended (7 posts)

  1. lucraft
    Member
    Posted 1 year ago #

    I am working on this site. As you will notice the title says '- Briarcroft Care Home' - however, with the code I am using it should show 'Site description - Briarcroft Care Home'....

    I started this topic believing that the code was the issue, however I have trawled forums and read WordPress docs and all the coding appears to be right. It just doesn't seem to recognise that 'About Us' is my home/front_page?!? Even using this...

    <title><?php bloginfo('name'); ?> | <?php is_home() ? bloginfo('description') : wp_title(''); ?></title>

    ...straight from from WordPress doc s does not work!

    Where am I going wrong?

  2. LIMEXS
    Member
    Posted 1 year ago #

    Have you used is_front_page() ?

  3. lucraft
    Member
    Posted 1 year ago #

    Thanks for the reply limexs.

    Yeah I have tried that in place of is_home() without any luck. :(

  4. LIMEXS
    Member
    Posted 1 year ago #

    I've checked the site again, I think you've set custom home page url.

    I think testing for condition bloginfo('name') == "" can be helpful.
    if condition is true we can output something echo 'string'

    otherwise, we can test condition like this $post->post_title == "About Us"

  5. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Try

    <title><?php bloginfo('name'); ?> | <?php if( is_home() || is_front_page() ) { bloginfo('description'); } : wp_title(''); ?></title>

  6. lucraft
    Member
    Posted 1 year ago #

    @limexs: thanks for the suggestion, although I was slightly confused at your post?
    Did you mean try "is_page('about-us')" ?

    If so, I'm sure this would have worked, however it's happened on a couple of sites I'm working on, so would rather not have to change the condition for each sites home page in the future.

    @esmi: I tried your suggestion which seems to be working, although I had to amend slightly to this...

    <title><?php bloginfo('name'); ?> | <?php is_home() || is_front_page() ? bloginfo('description') : wp_title(''); ?></title>

    ... and to get back to my original title 'layout', my final code became this:

    <title><?php is_home() || is_front_page() ? bloginfo('description') : wp_title(''); ?> — <?php bloginfo('name');?></title>

    Thanks for your help - I knew it must be simple!

  7. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Glad I could help :-)

Topic Closed

This topic has been closed to new replies.

About this Topic