2016-02-15, 08:46:51
(2016-02-15, 08:40:16)Carlos Wrote:(2016-02-14, 15:34:50)morvy Wrote: nice workaround for canonical urls, can you please tell me, how to achieve this also on nm_is_tag and nm_is_archive ? because they return root url too
Put this in your theme's functions.php file:
Code:function custom_get_header_nm() {
$canonical = false;
if (nm_is_single())
$canonical = nm_post_url(false);
elseif (nm_is_tag())
$canonical = nm_get_url('tag').rawurlencode(nm_single_tag_title('','',false));
elseif (nm_is_archive())
$canonical = nm_get_url('archive').intval($_GET[NMPARAMARCHIVE]);
if ($canonical) {
get_header(false);
echo "\n",'<link rel="canonical" href="',$canonical,'" />';
} else {
get_header();
}
}
Then in your template, replace
by:Code:<?php get_header(); ?>
Code:<?php custom_get_header_nm(); ?>
--
I may add some get_header replacement function like this to the plugin..
Yes, it's work perfeclty. thanks