Reputation: 660
I am using a Yootheme template for my wordpress site http://sribasu.com The theme is built on Warp Framework. My theme's head.php file prints page title after concatinating bloginfo name and wp_title ().
Unfortunately, the wp_title () function is not generating any output. As a result all my inner pages and blog post pages are having same title as homepage. Is there any issue with warp framework when using this function?
I am using wordpress 3.6. I have been trying to search google to see if it's a common issue or not. But didn't find a working solution yet. Please help.
Edit: The Code for head.php (/yoo_revista_wp/warp/systems/wordpress/layouts/head.php) is as follows:
<meta charset="<?php bloginfo('charset'); ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<?php if($this['config']->get('responsive', false)): ?>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php endif; ?>
<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
<link rel="shortcut icon" href="<?php echo $this['path']->url('template:favicon.ico');?>" />
<link rel="apple-touch-icon-precomposed" href="<?php echo $this['path']->url('template:apple_touch_icon.png'); ?>" />
<?php
wp_enqueue_script('jquery');
wp_head();
// set body classes
$this['config']->set('body_classes', implode(' ', get_body_class($this['config']->get('body_classes'))));
// get styles and scripts
$styles = $this['asset']->get('css');
$scripts = $this['asset']->get('js');
// compress styles and scripts
if ($compression = $this['config']->get('compression')) {
$options = array();
$filters = array('CSSImportResolver', 'CSSRewriteURL', 'CSSCompressor');
// set options
if ($compression == 3) {
$options['Gzip'] = true;
}
// set filter
if ($compression >= 2 && ($this['useragent']->browser() != 'msie' || version_compare($this['useragent']->version(), '8.0', '>='))) {
$filters[] = 'CSSImageBase64';
}
if ($styles) {
// cache styles and check for remote styles
$styles = array($this['asset']->cache('template.css', $styles, $filters, $options));
foreach ($styles[0] as $style) {
if ($style->getType() == 'File' && !$style->getPath()) {
$styles[] = $style;
}
}
}
if ($scripts) {
// cache scripts and check for remote scripts
$scripts = array($this['asset']->cache('template.js', $scripts, array('JSCompressor'), $options));
foreach ($scripts[0] as $script) {
if ($script->getType() == 'File' && !$script->getPath()) {
$scripts[] = $script;
}
}
}
}
// add styles
if ($styles) {
foreach ($styles as $style) {
if ($url = $style->getUrl()) {
printf("<link rel=\"stylesheet\" href=\"%s\" />\n", $url);
} else {
printf("<style>%s</style>\n", $style->getContent());
}
}
}
// add scripts
if ($scripts) {
foreach ($scripts as $script) {
if ($url = $script->getUrl()) {
printf("<script src=\"%s\"></script>\n", $url);
} else {
printf("<script>%s</script>\n", $script->getContent());
}
}
}
// add feed link
if (strlen($this['config']->get('rss_url',''))) {
printf("<link href=\"%s\" rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS 2.0\" />\n", $this['config']->get('rss_url'));
}
$this->output('head');
Upvotes: 0
Views: 1235
Reputation: 5903
From the codex:
The wp_title() function should not be used by a theme in conjunction with other strings or functions (like concatenating with bloginfo('name')) to write the content of the element, because it will render plugins unable to rewrite the whole title in case the plugins use the wp_title filter do the rewrite, which is the best practice. The use of this function is now a requirement for theme developers.
TESTED CODE:
<?php bloginfo('name'); ?><?php wp_title('»'); ?>
The first parameter, $sep: Text to display before or after (specified by $seplocation) the post title (i.e. the separator). Default: » (»)
Upvotes: 1
Reputation: 660
Got wonderful clue from Ben's response, I must admit. Finally identified the culprit Plugin - it is Contus Video Gallery. The plugin is good in what it does, but tampered my page titles :X
I fixed the wp_title filter function in the Contus Video Gallery plugin in /plugins/contus-video-gallery/hdflvvideoshare.php and it worked like a charm!
function add_video_title() {
global $wpdb;
$videoID = url_to_custompostid(get_permalink());
if (isset($_GET['p'])) {
$videoID = intval($_GET['p']);
}
if (isset($_GET['playid'])) {
$playId = intval($_GET['playid']);
}
if (!empty($videoID)) {
$videoID = $wpdb->get_var("SELECT vid FROM " . $wpdb->prefix . "hdflvvideoshare WHERE slug='" . intval($videoID) . "'");
$video_title = $wpdb->get_var("SELECT t1.name"
. " FROM " . $wpdb->prefix . "hdflvvideoshare AS t1"
. " WHERE t1.publish='1' AND t1.vid='" . intval($videoID) . "' LIMIT 1");
}
if (!empty($playId)) {
$video_title = $wpdb->get_var("SELECT t1.playlist_name AS name"
. " FROM " . $wpdb->prefix . "hdflvvideoshare_playlist AS t1"
. " WHERE t1.is_publish='1' AND t1.pid='" . intval($playId) . "' LIMIT 1");
}
if (!empty($video_title))
echo $video_title;
}
function add_video_title($title) {
if($_REQUEST['post_type']!='videogallery'){
return $title;
}
global $wpdb;
$videoID = url_to_custompostid(get_permalink());
if (isset($_GET['p'])) {
$videoID = intval($_GET['p']);
}
if (isset($_GET['playid'])) {
$playId = intval($_GET['playid']);
}
if (!empty($videoID)) {
$videoID = $wpdb->get_var("SELECT vid FROM " . $wpdb->prefix . "hdflvvideoshare WHERE slug='" . intval($videoID) . "'");
$video_title = $wpdb->get_var("SELECT t1.name"
. " FROM " . $wpdb->prefix . "hdflvvideoshare AS t1"
. " WHERE t1.publish='1' AND t1.vid='" . intval($videoID) . "' LIMIT 1");
}
if (!empty($playId)) {
$video_title = $wpdb->get_var("SELECT t1.playlist_name AS name"
. " FROM " . $wpdb->prefix . "hdflvvideoshare_playlist AS t1"
. " WHERE t1.is_publish='1' AND t1.pid='" . intval($playId) . "' LIMIT 1");
}
if (!empty($video_title))
return $video_title;
}
Upvotes: 0