Posts: 3,491
Threads: 106
Joined: Mar 2010
2011-06-05, 00:57:35
(This post was last modified: 2011-06-11, 18:42:30 by fotothink.)
If you want your homepage to have a customized title tag different to the default for all pages, you can do this.
1. Create a component 'titletag' with this content (edit 2nd and 4th lines to what you wish):
Code:
<?php if (return_page_slug()=='index') { ?>
This is my homepage's custom title tag...
<?php } else { ?>
<?php get_page_clean_title(); ?> - <?php get_site_name(); ?>
<?php } ?>
2. Edit your theme's template.php file (and/or others...) or header.php (if using Innovation theme), look for the <title>...</title> line and replace it with:
Code:
<title><?php get_component('titletag'); ?></title>
That's it.
Posts: 3,491
Threads: 106
Joined: Mar 2010
I've edited the post, as the Innovation theme has the <title> tag in header.php instead of template.php
Posts: 1,848
Threads: 86
Joined: Aug 2009
I've something like this before, but with the custom fields plugin - then calling the new field for the title if that partiular custom field is populated for that page.
-
Chris
Thanks for using GetSimple! - Download
Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Posts: 161
Threads: 6
Joined: Jan 2010
2011-06-12, 10:03:51
(This post was last modified: 2011-06-12, 10:04:37 by kuba.sanitrak.)
I usually only need to change the homepage's title too so usually just use this directly in the template.
Code:
<?php echo (get_page_slug(false) == 'index') ? 'Homepage title' : get_clean_title(false) . ' – ' . get_page_site_name(false); ?>
Posts: 3,491
Threads: 106
Joined: Mar 2010
sal Wrote:I usually only need to change the homepage's title too so usually just use this directly in the template [...]
I have also used that way. But the code you're inserting in your template(s) could be in the component I suggest. :-)
This way it is easier to work with when you have several templates, or if you change your theme.
I also find this faster, not having to locate the <title> line in your template file...
Posts: 3,491
Threads: 106
Joined: Mar 2010
ccagle8 Wrote:I've something like this before, but with the custom fields plugin - then calling the new field for the title if that partiular custom field is populated for that page.
Yeah, I thought about something like that (or did I read it here?).
Another (better?) solution would be having a plugin for this, as I suggested
in another thread.
But anyway I think that this 'titletag' component solution is a nice an easy one for most cases where you just want to do some SEO with your homepage.
Posts: 524
Threads: 48
Joined: Mar 2011
Something I implemented today for my H1 page heading by way of I18N Custom Fields. This outputs the custom field if it is populated:
Code:
<?php
if (return_custom_field('ueberschrift')) {
get_custom_field('ueberschrift');
} else {
get_page_title();
}
?>
Posts: 3,491
Threads: 106
Joined: Mar 2010
polyfragmented Wrote:Something I implemented today for my H1 page heading by way of I18N Custom Fields.
So you're doing like Chris, but exchanging fields: the
<title>... tag will always show the Page title field, but the body heading (
<h1>...) your custom title (if defined).
Interesting, a different approach.
Posts: 524
Threads: 48
Joined: Mar 2011
Carlos Wrote:So you're doing like Chris, but exchanging fields: the <title>... tag will always show the Page title field, but the body heading (<h1>...) your custom title (if defined).
Interesting, a different approach.
Oh, I actually apply this to the page title as well, but with yet another custom field. I just found it limiting to have a page called, say, "Search" with the same title and a H1 callled the same short string.
Here's my titel tag v00d00, a little compressed:
Code:
<title><?php if (return_custom_field('titel')) {get_custom_field('titel'); echo ' – '; get_site_name();} else {get_page_clean_title(); echo ' – '; get_site_name();} ?></title>
From a SEO point-of-view it's better to have the desired keywords in both the title
and the H1 element, but with this approach, I'm more flexible text-wise.