Musterknabe
Musterknabe

Reputation: 6081

get_meta_tags() not working with meta tags that contain the "itemprop" attribute

simple problem.

I have a site that uses meta tags. I want to extract the meta tags with PHP. However, when using "itemprop" in addition to "name" get_meta_tags() doesn't work.


<meta name="description" itemprop="description" content="Example content" />

Output of get_meta_tags()

false


<meta name="description" content="Example content" />

Output of get_meta_tags()

array (size=1) 'description' => string 'Example content' (length=157)

Do you have any idea why the itemprop addition makes such problems and if there's a method that can replace the get_meta_tags() or do I have to use sth. like phpQuery (since it's not recommended to use regex for html code)

Upvotes: 0

Views: 668

Answers (1)

unor
unor

Reputation: 96547

It is not valid to have a name attribute and Microdata’s itemprop attribute on the same meta element.

So your HTML should look like:

<meta itemprop="description" content="Example content" />
<meta name="description" content="Example content" />

Upvotes: 2

Related Questions