Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
in Q2A Core by
edited by

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
moved by
i have same situation
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...
For everyone who wants to test their website, use: https://search.google.com/structured-data/testing-tool/
Has this problem been fixed in ver 1.8.2?
@w101 Yes it has been fixed in 1.8.2. Note that if you have an advanced custom theme you may need to make some additional changes (check the functions that your theme overrides).

3 Answers

+3 votes
selected by
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 . '">');

All users will receive this error. You should do the main update.  Please update 1.8.2
The mainEntity fix did not fix it for me, still getting "mainEntity - A value for the mainEntity field is required."
Also the url fix did not solve the issue.

Testlink: https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fwww.mathelounge.de%2F591949%2Fgleichungen-quadratische-platte-quadratisch-ausgestanzt
Might be that absolute URLs are necessary for the URL items, see https://stackoverflow.com/q/38434422/1066234
I would also vote for changing from "http" to "https" for the "schema.org" domain, see https://schema.org/docs/faq.html#19
hi, i updated the files but still there is no "mainentity"  on the page's source code.
issue: https://github.com/q2a/question2answer/issues/700

screen: https://i.snag.gy/ZPhlCd.jpg

q2a: https://tosunkaya.com/cevaplar/

@Tosunkaya Update all files. Then the main entity issue gets up. But other problems continue.

Dostum Tüm dosyaları güncelle. O zaman main entity sorunu kalkıyor. Ancak diğer sorunlar devam ediyor.
@q2apro You have not added the mainEntity. In your code you should have something like
class="qa-main" itemprop="mainEntity" itemscope itemtype="http://schema.org/Question">
But you're missing itemprop="mainEntity".

@odevbul That's a different error, caused by the page title being outside the qa-main element. I added another change to my answer, can you test and see if it works for you?
Do you have a chance to replace these files and install them somewhere. I guess I couldn't make the change you wanted. Site down :)
@odevbul You haven't done the 'update 2' part. The "$extratags" are still being output on the "qa-main" element, not the "qa-body-wrapper" element.

@tosunkaya I've answered on GitHub. (P.S. I've hidden your comments here to avoid confusion as you're reporting a different issue. Feel free to post a separate question if needed.)
Hello Scott

Can you make these changes. I've tried a lot. but I don't understand what to do.
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.
@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?
Yes I did the bugfix update. In the default theme, the text warns, and in my theme, the name gives the warning.
edited by
resimag.com/p1/cdae5bd908.png  (Donut theme two error)
resimag.com/p1/f12c116af0.png  (Snowflat one error)

@Scott get all kinds of errors
Scott please answer.  qa-include/pages/question.php  on line 263 I have this:
    $qa_content['wrapper_tags'] = ' itemprop="mainEntity" itemscope itemtype="https://schema.org/Question"';
But there is not that "$qa_content['main_tags'] = ' itemscope itemtype="http://schema.org/Question"';" as you said.
Where is problem? Why couldn't I find the line that you wrote?
There is no line starting $extratags in main function in question-base.php. This is too bad, google can't index my website and anything doesn't help that you said.
Please, someone who have solved this problem helps me. Exactly error I get is "missing mainEntity.text field (optional)"
0 votes

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

This problem has been solved. I would like to see your site
check this question https://www.nirbik.com/36209/

this is an unanswered question.
its give you error not warning.
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
minus vote note giving any error.
0 votes

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"
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.
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).
This problem seems to be with some themes, I tried cleanstrap and this error is not there just cleanstrap is outdated.