0

A few days ago I set the title tag for my home page by doing this:

Settings => General

but it turned out that this didn't just change the title of the home page. It actually changed the title of every page on the site to that one title.

What is the way for me to correctly set the title for the home page, and not over-write the titles for all the individual pages?

EDIT:

To explain things further. I set the title tag to be this:

<title>0xdata - Open source software engineering developer community and events</title>

But now the individual pages have titles like this:

Title - Open source software engineering developer community and events » Open source software engineering developer community and events

Thank you!

5
  • What do you mean by "changed the title of every page on the site to that one title". It changed <title> tag contents only, I guess? Or did it overwrite posts titles in database? (This would be very strange). Commented Jul 11, 2013 at 18:45
  • @KrzysiekDróżdż What happened was that every <title> tag on every tag got switched to whatever I set it to. But I only intended to set the <title> on the home page. Does that help explain it?
    – Genadinik
    Commented Jul 11, 2013 at 18:46
  • Can you show me, how does your theme output this <title> tag? You could find it in header.php file of your theme, I guess. Commented Jul 11, 2013 at 18:50
  • Your wp_title is designed for your pages something like: if ( is_page() ) { single_post_title('') - get_bloginfo( 'name' ); }, so it's echoing site name with page name. You can edit the wp_title to not to echo the site name with the page title. But first confirm that, the thing is like that as @Krzysiek mentioned. Commented Jul 11, 2013 at 18:51
  • @MayeenulIslam I just edited my original question to make it more clear. It sounds like the issue is the one I am experiencing. Would you know how I can make Wordpress not add the general title to the titles of individual pages?
    – Genadinik
    Commented Jul 11, 2013 at 18:53

3 Answers 3

2

WordPress sets the titles of your pages using tags which is normally set int he header.php file of your theme. In my themes I use:

<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>

Find your themes header.php and try changing the code inside the tags to the code above.

6
  • thank you. So what does bloginfo('name') take its value from? And is the wp_title() the title that I had set from General-->Settings ?
    – Genadinik
    Commented Jul 11, 2013 at 19:00
  • settings->general->site-title is the bloginfo('name'); . wp_title() is the name of the post, or page that you are viewing. So the title of a blog with the name of My Blog, when viewing a page called 'My Page' would display in the title as My Blog < My Page .
    – Vigs
    Commented Jul 11, 2013 at 19:02
  • thank you - I'd like to take a look at my header settings. Would you know how I can take a look at my header.php?
    – Genadinik
    Commented Jul 11, 2013 at 19:19
  • You will need FTP (File transfer protocol) access to your web server. Most service provides provide a web app that supports FTP, it will be labeled FTP client. Or you can use a 3rd party program like fireFTP that works right in your browser to access your webserver. Once your connected to your web server you have to navigate to /wordpress/wp-content/themes/YOUR-THEME-NAME-HERE/ header.php should be in that folder.
    – Vigs
    Commented Jul 11, 2013 at 19:27
  • In your /wp-admin, in Appearance tab click on the Editor. Then choose the Header header.php from the right to edit it. But before any edit take a BACK UP of the file for any miscode. Commented Jul 11, 2013 at 19:27
2

The Site Title is what you set in Settings => General. Usually, a theme will append the page's title at the end of that string. For example

My Website Blog | About Me

In order to achieve that, you'd need to utilize wp_title(). You could, alternatively, use an SEO plugin to automate this if you are not comfortable playing around with code.

I recommend WordPress SEO Plugin • Search Engine Optimization Plugin • Yoast. It can make the necessary changes for you and give you some nice options for templating your titles.

Let me know if this helps.

4
  • thank you. I have Yoast installed. But how can I use it to set the title? It seems to get overwritten.
    – Genadinik
    Commented Jul 11, 2013 at 18:57
  • SEO -> Titles & Meta -> General: I check "Force rewrite titles". Then in Post Types tab this is my template: %%title%% - %%sitename%% which will create About Me - My Website Blog
    – GhostToast
    Commented Jul 11, 2013 at 18:59
  • thank you! Would you know how I can view my header.php file?
    – Genadinik
    Commented Jul 11, 2013 at 19:18
  • With a text editor. It would be located at wp-content/themes/theme-folder-name/header.php. In a pinch you can modify it using the Appearance -> Editor. But that's pretty bad practice.
    – GhostToast
    Commented Jul 11, 2013 at 20:39
1

This elaborative <title> tag will let you understand what and how exactly <title> tag works in WordPress.

<title><?php
    if ( is_single() ) { single_post_title(); }       
    elseif ( is_home() || is_front_page() ) { bloginfo('name'); print ' | '; bloginfo('description'); get_page_number(); }
    elseif ( is_page() ) { single_post_title(''); }
    elseif ( is_search() ) { bloginfo('name'); print ' | Search results for ' . esc_html($s); get_page_number(); }
    elseif ( is_404() ) { bloginfo('name'); print ' | Not Found'; }
    else { bloginfo('name'); wp_title('|'); get_page_number(); }
?></title>

Thanks to Ian Stewart for this nice bunch of codes.

Explanation: is_single() means the post detail page, is_page() means the page detail page (i.e. web pages), is_search() means the search result page, and the is_404(), is_home(), is_front_page() are self-explanatory. And a bar (|) is used as separator between two different texts.

So you can see that, using these bunch of codes, it won't show the site title into the inner web pages, because, you set if ( is_page() ) { single_post_title(''); }, it will show only the page title.

Though this is not a smart way to implement the <title> of a WordPress site, but it's a nice one to understand the core of the <title> tag. And the sweetest part of it that, you can use this bunch of codes into your theme header.php's <title> tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.