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

3 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
Thanks.
All users will receive this error. You should do the main update.  Please update 1.8.2
by
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
by
Might be that absolute URLs are necessary for the URL items, see https://stackoverflow.com/q/38434422/1066234
by
I would also vote for changing from "http" to "https" for the "schema.org" domain, see https://schema.org/docs/faq.html#19
by
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/

@Scott
by
@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.
by
@q2apro You have not added the mainEntity. In your code you should have something like
<div
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?
by
@Scott
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 :)
by
@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.)
by
Hello Scott

Can you make these changes. I've tried a lot. but I don't understand what to do.
by
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.
by
@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?
by
https://github.com/q2a/question2answer/tree/bugfix
Yes I did the bugfix update. In the default theme, the text warns, and in my theme, the name gives the warning.
by
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
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
This problem has been solved. I would like to see your site
by
check this question https://www.nirbik.com/36209/

this is an unanswered question.
its give you error not warning.
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.
...