0

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?

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' );
  • @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 '16 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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