GetSimple Support Forum

Full Version: Changing metatags (DOM ready)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

On a dynamical product page I want to change the metatags (SEO) with the actual product information.

I've made the following with jQuery but does this change make sense (for SEO) after DOM is ready? The page source is not showing the changed metatags, with Firebug it does.

Code:
$('meta[name=description]').attr('content', '<?php echo $description; ?>');
$('meta[name=keywords]').attr('content', '<?php echo $keywords; ?>');

... or ...

$('meta[name=description]').remove();
$('head').append( '<meta name="description" content="<?php echo $description; ?>">' );
    
$('meta[name=keywords]').remove();
$('head').append( '<meta name="keywords" content="<?php echo $keywords; ?>">' );

Is there a way (function) to change this after function get_header(); is started?

Regards, René
Hi Rene,

I don't really understand why you would need to do this. The keyword tag is obsolete for SEO and the description nearly so.
(2014-01-23, 21:26:03)Timbow Wrote: [ -> ]Hi Rene,

I don't really understand why you would need to do this. The keyword tag is obsolete for SEO and the description nearly so.

Ok, ok, I know. Let's not get bogged down in a discussion about this. Posts with meta keywords had more relevant ads than posts without it. For that I believe the meta tags are still very important and DOES matter. As far as the ranking there are plenty of pros and cons. It does not hurt adding them.

My question is not about why but how!
(2014-01-23, 22:42:53)Rene Wrote: [ -> ]My question is not about why but how!

You can alter global variable $metak BEFORE calling get_header()
(2014-01-24, 06:23:31)Carlos Wrote: [ -> ]
(2014-01-23, 22:42:53)Rene Wrote: [ -> ]My question is not about why but how!

You can alter global variable $metak BEFORE calling get_header()


Thx Carlos, have noticed this global. But therefore have to setup the productpage & vars before calling get_header(). But I was just thinking, a search for metatags with %product_meta_% and replace it with the right info (plugin hook/filter content).
Back to the drawingboard for me Cool
You can use the index-pretemplate hook.
You cant filter meta keywords.
You will have to manipulate the global carlos mentioned.
@Carlos, @shawn_a,
Thx, I will try that. I've just noticed the above mentioned jQuery code caused pages to stop (due errors) so I disabled it. Anyway, changing meta server side is much better.