TransWikia.com

Adding microdata using Structured Data Markup Helper HTML

WordPress Development Asked by Desislava Angelova on December 6, 2020

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?

One Answer

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' );

Answered by cjbj on December 6, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP