Before you ask please READ THIS

Homepage title tag re-writing problem

edited March 2013 in Hypershot Posts: 23
Hi,

On my site joshuamcghie.com I have set the front page to be an Album called 'Portfolio'. Problem is, the title tag for the album is used as the site title.

How can I have the front page display the album but have a different title tag to that when the actual album is linked to?

For example, I want 'Joshua McGhie - Photographer' as the title tag for the homepage which displays the album, but 'Portfolio' when the album is displayed in its native url (not the homepage url).

Hope this makes sense :)

Comments

  • AirAir
    Posts: 10,970
    Hello,

    Have you tried any SEO plugins for such title control?

    We can try to produce code for that but link could be useful to get best understanding.

    With regards.
  • Posts: 23
    Thanks for the prompt reply.

    I have tried SEO plugins but no change. The problem is, when you set the homepage to be a 'static page' using wordpress and then set an album to display from that page, the title tag will always match the title of the album. It sort of pulls the entire title through.

    I set the title tag for the album using an SEO plugin and that works great. So when I go to the direct url for that album it displays its title that I set. Good.

    But when I set the album to display as the homepage, it also uses the title of the album. I want it to use the title of the static front page or the title of the site in only this instance when displaying the root domain page for the site.

    Hope this makes sense.

    Probably need a single line of code for front page.php which allows me to set the title for the root page of the url only, and then obey the normal wordpress and SEO plugin rules for everything else.

    Url is http://www.joshuamcghie.com for homepage

    Direct album link is http://www.joshuamcghie.com/album/portfolio/

    Thanks so much for looking into this. Your support is amazing.
  • Posts: 23
    I think what might fix things is the following.

    I have my site set to show a static page on the homepage. I set this on the Settings->Reading->FrontPage. The title of this page is 'Welcome'. I have used Yoast SEO to present the title of this page as 'Joshua McGhie | Photographer'.

    I have created an Album titled 'Portfolio'. I have used Yoast SEO to present the title as 'Joshua McGhie - Portfolio'.

    I have set the front page to present the 'Portfolio' album by going to Hypershot->MainSettings->FrontPage and selecting 'Selected Album' and 'Portfolio' as the selection.

    When I visit www.joshuamcghie.com the title is 'Joshua McGhie | Portfolio'. When I visit www.joshuamcghie.com/portfolio the title is 'Joshua McGhie | Portfolio'.

    I want the homepage to reflect the title tag set for the 'Welcome' page, which would make the most sense. But it is using the title tag for the album name.

    I think there just needs to be a bit of code so the theme will use the title of the page set to be the front page when using an album. Perhaps a snippet in the frontpage.php?

    Your help on this is much appreciated, and if the change could be rolled into the next version of the theme also that would be great!

    Thanks so much.



  • AirAir
    Posts: 10,970
    WOW for such detailed description!! I understood the problem, but now there is just no chance for misinterpretation ;-)

    Anyway changes are not so easy, and I don't know about adding this to Theme, as not everybody uses SEO plugins. However you can make this changes in child theme to not lose them. Also I will mark this topic for myself and think about it.

    First lets roll to header.php, so you can clean up if you like(NO NEED TO DO THIS STEP), and change code
    
            wp_title( '|', true, 'right' );
    
            // Add the blog name.
            bloginfo( 'name' );
    
            // Add the blog description for the home/front page.
            $site_description = get_bloginfo( 'description', 'display' );
            if ( $site_description && ( is_home() || is_front_page() ) )
                echo " | $site_description";
    
            // Add a page number if necessary:
            if ( $paged >= 2 || $page >= 2 )
                echo ' | ' . sprintf( __fe( 'Page %s' ), max( $paged, $page ) );
    to
    
            wp_title( '|', true, 'right' );
    
    Now our two main changes:
    front-page.php line ~50

    global $wp_query;

    //get album to show
    to

    global $wp_query;

    define('ALBUM_FP_TITLE', wp_title("", false));
    //get album to show
    Next
    header.php
            wp_title( '|', true, 'right' );
    to
    echo defined('ALBUM_FP_TITLE')? ALBUM_FP_TITLE : wp_title( '|', false, 'right' );
    With regards.
  • Posts: 23
    Thank you again for your help on this. You provide such great support for your themes.

    Would you be able to walk me through how to make these changes to the child theme? I haven't used child themes before. I have a basic understanding of their purpose, but not sure how to actually implement these changes in that way.

    Regards

  • Posts: 23
    Also,

    I made the changes you specified and there is no change in behavior. The album title tag is still being used as the homepage title tag when the album is set to display on the homepage.

    A little more help?
  • Posts: 23
    Having a closer look, if I disable the Yoast SEO plugin your code changes 'sort of' work.

    The homepage title becomes 'www.joshuamcghie.com' and the portfolio title becomes 'Portfolio | ' but this is not right either.

    So something has changed when SEO plugin is off (but incorrectly) and when SEO plugin is on, nothing happens differently.

    Hope this feedback helps to pinpoint the issue.
  • Posts: 23
    Sorry, just one last thing. For my own site, I would be happy with some code that just hard coded the title for the homepage (and only the homepage) if this makes things easier?
  • AirAir
    Posts: 10,970
    Hello.
    I have tested this changes with Yoast SEO plugin, so no need for hard coding anything. After this changes it will use title set for front page.

    Try doing this changes in normal theme again. If you will succeed then I will guide how to make this changes in child theme if it will be needed.

    If you have some cache plugin then disable it to be sure that there are any effects visible.

    With regards.
  • Posts: 23
    Hi,

    I have re-made the changes and double checked everything 5 times, but there is still no change :(

    Perhaps you could take a quick look at my site for me, as I am totally stuck as to why your suggested changes are not working.

    I will PM you login details now.

    Thank you!
  • AirAir
    Posts: 10,970
    Hello:-)

    I have spend some time on your site, and I can't find differences in my and your installation and configuration of SEO plugin BUT on your site it is hijacking title tag(remove form HTML, and inserts it again) while on my it is left as it was.
    That is the reason why it shows wrong title.

    Maybe you did some changes somewhere in source or in plugin that could be effecting in this way?

    With regards.
  • Posts: 23
    Thanks for taking a look.

    I haven't made any other source code changes. Could one of the other plugins I have running be causing the issue? I will start disabling them to see if I can find the problem.

    In the mean time, would you be able to provide me with a hard-coded title solution for the home page? I will not be changing the title of the homepage again, so is not an inconvenience to hard code it if it will just work. Is a bit of a hack, but I don't mind :)

    Thanks
  • Posts: 23
    Just to provide you with an update - I tried disabling all plug-ins but the problem persists.

    The only code I have changed is the code you have asked me to.

    Any other ideas?
  • AirAir
    Posts: 10,970
    Hello,

    Unfortunately cause SEO plugin is hijacking <title> tag, there is no way that any hardcoded solution will work, as this what I gave you was almost hardcoded.

    I am just changing flat so I will have NO extra time to search why in your case it is working this way. Only thing we can do is hard coding solution but without using this SEO plugin.

    With regards.
  • edited March 2013 Posts: 23
    Thanks Air.

    For anyone else having this issue, try putting the code at the following link at the top of your functions.php:

    http://pastebin.com/5cCmhLiQ

    Make sure you edit the relevant bits in the code to suit your site's title, description and keywords.

    Hope this helps someone - is working perfectly for me :)
    Post edited by JackieR0 on
  • AirAir
    Posts: 10,970
    Wow great Tip, thanks!
    Sorry that I wasn't helpful enough.

    With regards.
  • Posts: 23
    No worries at all. You are always super helpful - just wanted to get it sorted right away. I am a little impatient like that :)
  • Posts: 13
    Air...you are my hero guy :-)
  • AirAir
    Posts: 10,970
    I don't know why, but thanks :-)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!