Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+7 votes
7.2k views
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. 

Sample 

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

Sample 

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
by
moved by
i have same situation
by
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...
by
For everyone who wants to test their website, use: https://search.google.com/structured-data/testing-tool/
by
Has this problem been fixed in ver 1.8.2?
by
@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).

5 Answers

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

by
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?
by
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)"
by
@scott
Sir, would you please explain the update 2.
I did not change it. May be for that reason I get warning in line 232. Please check it and give me solution
 
https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fwww.ask-ans.com%2F5000
by
edited by
+1
I'm getting this mainEntity.text warning in Google Search console in 2021 July. Latest q2a and snow flat theme.

Update: it was because one question had no description. Deleting or adding description text will solve the problem.
0 votes
by

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->body_prefix();

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

    $this->donut_site_header();

    $this->output( '<div class="container visible-xs">' );
    $this->output( '<div class="top-search-bar">' );
    $this->search();
    $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->notices();
    $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->page_title_error();
    $this->output( '</div>' );

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

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

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

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

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

    $this->main();

    if ( !$this->donut_do_hide_sidebar() ) {
        $this->sidepanel();
    }

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

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

    $this->body_suffix();
}
by
@scott question without answer is giving error not warning.please check
by
This problem has been solved. I would like to see your site
by
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
by
minus vote note giving any error.
0 votes
by

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

Hey. Help. How to fix the problem in the theme:  Donut theme.

 Donut theme 

Donut theme

Donut theme

by
Testing please https://www.odevbul.org/odev-sor/3206

qestions no vote
Mail adress send pm. You send mu theme three day later
by
mc_9@mail.ru.  THX)_
by
merhaba türkçe biliyorsun sanırım aynı hata bendede var lütfen bu konuda yardımcı olsan bir türlü bulamadım donut temasını kendi sitesinden dün indirdim. güncel deilmi ek sorun paketi filanmı var
by
Bug fix olanı indirmen lazım
+1 vote
by



https://search.google.com/structured-data/testing-tool/?hl=tr#url=https%3A%2F%2Fodevvebilim.com%2Fsoru%2F1117%2Fbohr-atom-modeline-gore-atomun-temel-uyarilmis-ve-iyon-hallerini

question2answer 1.8.3
donot theme 2.0.2
latest version snow flat..

I'm filling in all the fields, but still gives this error

...