Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing metatags (DOM ready)
#1
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é
Reply
#2
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.
Reply
#3
(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!
Reply
#4
(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()
Reply
#5
(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
Reply
#6
You can use the index-pretemplate hook.
Reply
#7
You cant filter meta keywords.
You will have to manipulate the global carlos mentioned.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#8
@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.
Reply




Users browsing this thread: 1 Guest(s)