2023-09-09, 19:48:08
(2011-06-24, 06:09:41)Carlos Wrote:robkellas Wrote:Is there a way to have page titles include the post title? This would be an excellent addition that would benefit SEO.
If anyone else has the answer please let me know.
Quick patch:
Create a functions.php in your theme folder, with this (if file exists, insert the function into it):
Code:<?php
function nm_echo_title() {
global $NMPAGEURL;
$url = strval(get_page_slug(false));
if ($url == $NMPAGEURL) {
if (isset($_GET['post'])) {
$slug = str_replace('..','',str_replace('/','',$_GET['post']));
$file = NMPOSTPATH . $slug . '.xml';
$post = @getXML($file);
if (!empty($post) && $post->private != 'Y') {
echo strip_tags(strip_decode($post->title)),' - '; // ' - ' is the separator
}
}
}
}
Now edit your theme: look for your <title>...</title> tag in your template.php (or header.php if using Innovation theme) file, and insert this call just after the opening <title> tag:
Code:<?php nm_echo_title(); ?>
Example (based on Cardinal theme):
Code:<title><?php nm_echo_title(); ?><?php get_page_clean_title(); ?> < <?php get_site_name(); ?></title>
That's it.
Post titles will now be like: This is the post title - News page < My site name
Would it be possible to display only the post title without the news page title? Something like this:
Code:
<title><?php nm_echo_title(); ?> < <?php get_site_name(); ?></title>
-----------------------------------------------------
Premium HTML5 Ad Banners, Google Ads
and Campaigns
https://netrocket.ch
https://www.kontiko.ch
-----------------------------------------------------
Premium HTML5 Ad Banners, Google Ads
and Campaigns
https://netrocket.ch
https://www.kontiko.ch
-----------------------------------------------------