Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

schema.org errors - mainEntity missing

+4 votes
asked Dec 4 in Q2A Core by odevbul
edited Dec 6 by Scott

With a new update from Google, I noticed the difference in search results. But structural data seems to be lacking. There are some errors. 


http://schema.org/Answer (url) 


http://schema.org/QAPage (Mainetity) 

See the link below to see the results. 

https://search.google.com/structured-data/testing-tool/u/0/?hl=tr#url=https%3a%2f%2felectronics2electrical.com%2f2441%2fwhich-device-use-to-convert -dc-to-AC

Q2A version: 1.8.1
commented Dec 4 by taufik7000
moved Dec 4 by Scott
i have same situation
commented Dec 4 by Scott
Thanks for the URL. (I hid your other question since they're asking the same thing.)
Checking into it now, but the description of "mainEntity" is not making any sense right now...
commented Dec 11 by q2apro
For everyone who wants to test their website, use: https://search.google.com/structured-data/testing-tool/

3 Answers

+3 votes
answered Dec 4 by Scott
selected Dec 7 by odevbul
Best answer

OK here's what you need to do to fix the error. In the file qa-include/pages/question.php on line 263, change this:

$qa_content['main_tags'] = ' itemscope itemtype="http://schema.org/Question"';

to this:

$qa_content['main_tags'] = ' itemprop="mainEntity" itemscope itemtype="http://schema.org/Question"';

To fix the warnings about the missing URLs, in qa-include/qa-theme-base.php on line 1962 change this:

$this->output('<a href="' . $post['what_url'] . '" class="' . $classes . '">' . $post['what'] . '</a>');

to this:

$this->output('<a itemprop="url" href="' . $post['what_url'] . '" class="' . $classes . '">' . $post['what'] . '</a>');

Not sure why Google suddenly decided to make this an error as it worked perfectly fine before. From my research it seems that the "mainEntity" should be optional.

Nonetheless, I'll add the above into the next version of Q2A (though the url fix needs to be more generic and respond to the microdata config option). Since Google has officially announced they're using the Q&A structured data it's possible we'll be getting more people checking their sites.

UPDATE: I've just pushed some changes to the bugfix branch on GitHub that should solve the problem.

UPDATE 2: for the missing name problem, change the following lines. In qa-theme-base.php in the body_content function change the qa-body-wrapper line to this:

$extratags = isset($this->content['main_tags']) ? $this->content['main_tags'] : '';
$this->output('<div class="qa-body-wrapper"' . $extratags . '>', '');

Then in the main() function remove the line starting $extratags = then change the next line to:

$this->output('<div class="qa-main' . $hidden . '">');

commented Dec 6 by odevbul
Scott gives different errors when I change the theme. The name I'm talking about gives you a text error. I even tried to use your theme.

This is really annoying.
commented Dec 6 by Scott
@odevbul I've just pushed another update to the bugfix branch on Github that has the changes I mentioned in "update 2". It works with the default themes. Can you try that and let me know if it work for you?
commented Dec 6 by odevbul
Yes I did the bugfix update. In the default theme, the text warns, and in my theme, the name gives the warning.
commented Dec 6 by odevbul
edited Dec 6 by odevbul
resimag.com/p1/cdae5bd908.png  (Donut theme two error)
resimag.com/p1/f12c116af0.png  (Snowflat one error)

@Scott get all kinds of errors
0 votes
answered Dec 7 by Scott

OK take 2 on this :) I realised I hadn't pushed up the changes to the bugfix branch, so they are now live. All the default themes definitely work correctly now.

Themes that have overridden the main() or body_content() functions may require changes. I sent a pull request to Ami for the Donut theme as that appears to be popular. You can copy the changes you see there, or I've put the whole body_content function below. In the file qa-donut-layer.php in the theme, replace the entire function with this:

function body_content()
    $sub_navigation = @$this->content['navigation']['sub'];

    if ( $this->template === 'admin' ) {
        unset( $this->content['navigation']['sub'] );

    $navigation = &$this->content['navigation'];

    if ( isset( $navigation['cat'] ) ) {
        donut_remove_brackets( $navigation['cat'] );


    $this->output( '<div class="container">' );
    $this->output( '<div class="top-divider"></div>' );
    $this->output( '</div>' );


    $this->output( '<div class="container visible-xs">' );
    $this->output( '<div class="top-search-bar">' );
    $this->output( '</div>' );
    $this->output( '</div>' );

    $extratags = isset($this->content['wrapper_tags']) ? $this->content['wrapper_tags'] : '';
    $this->output( '<div class="qa-body-wrapper"' . $extratags . '>', '' );

    $this->output( '<main class="donut-masthead">' );

    $this->output( '<div class="container">' );
    $this->output( '</div>' );

    $this->output( '<div class="container">' );

    $extra_title_class = $this->donut_page_has_favorite() ? ' has-favorite' : '';

    $this->output( '<div class="page-title' . $extra_title_class . '">' );
    $this->output( '</div>' );

    $this->output( '</div>' );

    $this->output( '</main>' );

    $this->output( '<div class="container">', '' );

    $this->widgets( 'full', 'top' );
    $this->widgets( 'full', 'high' );

    if ( !empty( $sub_navigation ) ) {
        // create the left side bar
        $this->left_side_bar( $sub_navigation );


    if ( !$this->donut_do_hide_sidebar() ) {

    $this->widgets( 'full', 'low' );
    $this->widgets( 'full', 'bottom' );

    $this->output( '</div> <!-- END container -->' );
    $this->output( '</div> <!-- END body-wrapper -->' );

commented 4 days ago by odevbul
This problem has been solved. I would like to see your site
commented 4 days ago by fahimalfarhan
check this question https://www.nirbik.com/36209/

this is an unanswered question.
its give you error not warning.
commented 4 days ago by odevbul
I looked at the question. There are some questions on your site that some do not have error.
1. If there is no question description
2. If there is no question or no answer
3. If the problem minus the vote can give an error
commented 4 days ago by fahimalfarhan
minus vote note giving any error.
0 votes
answered Dec 10 by Ahmed S

Two warnings occur in two cases

1. When there is a question without content
The "Text" event is recommended to populate the text field. Please enter a value if available.

2. If there is no answer to the question
"You must make one of acceptedAnswer or suggestedAnswer"
commented Dec 10 by odevbul
Require text input in questions. And add a response to all missed questions.

This question is waiting to be answered.

These are just warning. I'm dealing with them.
commented Dec 11 by Scott
For both of these the code Q2A produces is correct. If your question doesn’t have any text what are you supposed to put in there? And if there are no answers yet, how can you have a suggestedAnswer?

It’s all correct as per the schema.org definition. I’ve reported the missing answer error as a bug to Google, I suggest you do the same (there is a send feedback button on the testing tool).