• I need to apply a specific page title that isn’t the site title or the post name but a line of text that I dictate, to the home page only (a posts page) of my website.
    I’m pretty sure if I use conditional code in the header I can call in something that’s unique to the home page but I don’t know php and I can only find code to alter the order in which the blog name and posts title are called in the Codex – can anyone help please?

Viewing 15 replies - 1 through 15 (of 15 total)
  • What theme are you using? Where did you download it from?

    Thread Starter Karen_R

    (@karen_r)

    It’s a custom theme adapted from a paid theme called Ekho, downloaded from Themeforest at https://teothemes.com/
    At the moment the code is simply:
    <title><?php wp_title(‘-‘);?></title>

    Have a look at the is_page() conditional. Please bear in mind that, as you are using a commercial theme, you need to seek support from the theme’s developer/vendor. We do not support commercial products here.

    Thread Starter Karen_R

    (@karen_r)

    I also want to do the same to another site that’s in Twenty Twelve once I have that online so the same question still applies.

    The is_page() condition will apply it to all page not just the home page so I would have thought I should use the is_home() condition – I’m just not sure how to write the code – I’m thinking it would be something like:
    ‘<title><?php if ( is_home() ) { my page title goes in here } ?> </title>’
    Does that look right?

    We would need to see your custom Twenty Twelve child theme before we could help with that.

    Thread Starter Karen_R

    (@karen_r)

    It’s not a child them I’m using it out of the box at https://www.adderburyliteraryfestival.co.uk
    I don’t want to change the site name just the title code on the home page but keep the other pages the same

    You are pretty close @karen_r! Try this:

    if ( is_home() || is_front_page() ) {
    	echo '<title>My unique title here, just on homepage</title>';
    } else {
    	//copy or adapt your standard title code here from your theme
    }

    Do not edit the Twenty Twelve theme. It is the current default WordPress theme and having access to an original, unedited, copy of the theme is vital in many situations. First create a child theme for your changes.

    @jonnyauk: Please stop advising people to edit the main theme instead of creating a child theme for their changes.

    Fair point… but at no point did I suggest *where* this code should be used, so please relax @esmi – I’d have thought that anyone working with themes would be using a child theme these days (but a-lot of users don’t… they just hack themes up to their hearts content!) I do however agree that child themes are certainly the way to go.

    Thread Starter Karen_R

    (@karen_r)

    @jonnyauk – thanks for your help, straight and clear answer exaclty what I wanted – much appreciated!!

    Well – glad I helped. @esmi does have a very valid point though – you can save yourself a-lot of trouble by using a child theme, there dead simple to setup and it will allow you to ‘update’ the parent theme (Twenty Twelve in your case) whilst still retaining any custom code you have created.

    Take a read over the link that @esmi suggested from the Codex – it well worth exploring ??

    Thread Starter Karen_R

    (@karen_r)

    Thanks both – I’m in the middle of writing the child theme and this title question is part of what I’m trying to achieve, I just thought it would be simpler to let you know that I hadn’t made any changes to the parent yet…..

    at no point did I suggest *where* this code should be used

    Exactly! You do not warn the poster to use a custom CSS plugin or a child theme as appropriate.

    so please relax @esmi

    Sorry but you have already been asked about this once. It’s the forum regulars that have to pick up the pieces when these theme edits go wrong. And it’s the people that you have “helped” who can end up with all of their changes being wiped out.

    hi pls i cant seem to understand how to build a website and not a blog pls answer quickly

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘conditional code to call unique title for page’ is closed to new replies.