|
|
#1 (permalink) |
|
Business Guru
Join Date: Dec 2003
Location: Near Inverness, Highlands, Scotland
Posts: 7,671
|
One thing I find really annoying about Wordpress - the default page titles.
From a SEO standpoint, you really just want the page name in the title - but Wordpress throws in Site name >> Page Name. It should be simple to edit - after all, the default Wordpress title appears as: Code:
<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
Code:
<title><?php wp_title(); ?></title> >> Page Title Here's the fix: Code:
<title><?php wp_title(($sep = '')); ?></title> So apply that you end up with: Page Title as your title. ![]() A very simple, but bloody useful tip. ![]() Thanks to Bruce Lawson for that, and there are a few more small - but useful - editing tweaks here: http://www.brucelawson.co.uk/2005/wo...ibility-hacks/ ADDED: Okay, that removes the blog name from the index page. Damn. Need to find an expression to allow wp_title in posts AND categories, while allow for bloginfo in the index. Otherwise, a simple work around: Code:
<title><?php wp_title($sep = ''); ?>: <?php bloginfo('name'); ?></title>
Page title: Blog name
__________________
SEO specialist |
|
|
|
|
|
#2 (permalink) | |
|
Junior Member
Join Date: Apr 2007
Posts: 4
|
Quote:
|
|
|
|
|
|
|
#3 (permalink) |
|
Member
Join Date: May 2007
Location: Wellingborough, Northants
Posts: 4
|
I don't know wordpress but I can offer my 2 cents on the PHP code. Apologies if I'm either stating the obvious or on the other hand blinding people with science, unfortunately I'm not yet aware of the levels of technical ability of people on this forum.
Firstly, I think there's a difference between: 1. wp_title(($sep = '')) and 2. wp_title($sep = '') the second version provides a named parameter value to the function, whereas the first version (I think, pretty sure) creates a local variable, assigns it a value of '', and the result of that assign (i.e. '') is passed as the first parameter to the function. So they both work, but the second version is correct. As for a solution to the problem, an immediate if can be used to get an expression which returns one value if title is blank and another value if title is available. An immediate if is something like: (condition) ? (value if condition is true) : (value if condition is false) In this particular case: Code:
<title><?php ( '' == trim(wp_title($sep='',$display=false)) ) ? bloginfo('name') : wp_title($sep=''); ?></title>
Since both functions echo the result by default, the first call to wp_title in the condition part has to be told not to echo but return the result, I checked the wp_title function code and this is done with the $display=false parameter. |
|
|
|
|
|
#4 (permalink) |
|
Business Guru
Join Date: Dec 2003
Location: Near Inverness, Highlands, Scotland
Posts: 7,671
|
Paul, you're a star - just tested it out and works exactly as required.
![]() (I never was very good with languages ... )
__________________
SEO specialist |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|