1

I am trying to add schema microdata to a wordpress website. I have tried to insert some microdata directly in the wp editor (text mode) but every time i save the page it does not save the code.

I tried a few plugins but when I check with the structured testing tool it doesn't seem like they are working.

I generated the microdata using this tool, but I am not able to edit the html. Can I do it via cpanel? I cannot find how i can edit the html under the cpanel.

How can I add the generated data to the home page?

1
  • May you please provide an example of a "schema microdata"? Sep 14, 2016 at 1:43

2 Answers 2

0

By default TinyMCE, the (visual) editor of WordPress, strips schema microdata from input. There are plugins (example) that will prevent this behaviour. Or you can do it yourself by adding this snippet to your functions.php (docs):

function wpse238918_allow_schema ($in) {
    if(!empty($in['extended_valid_elements']))
        $in['extended_valid_elements'] .= ',';
    $in['extended_valid_elements'] .= '@[id|class|style|title|itemscope|itemtype|itemprop|datetime|rel],div,dl,ul,dt,dd,li,span,a|rev|charset|href|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur]';
    return $in;
    }
add_filter('tiny_mce_before_init', 'wpse238918_allow_schema' );
1
  • @DesislavaAngelova Great that worked. Please accept this answer (check to the left), so this question does not appear as 'unsolved' in the system later on.
    – cjbj
    Oct 25, 2016 at 8:49
0

Another approach without any code injections is using a wordpress plugin to configure Classic editor to accept all metadata specific content.

Plugin is called: Advanced TinyMCE Configuration

Its configuration is: @[itemscope|itemtype|itemid|itemprop|content],div,span,h1,h2,h2,h4,h5,h6time[datetime]

More info here: https://bghints.blogspot.com/2023/03/stop-wordpress-from-removing-microdata.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.