Für mein Frage und Antwort Portal – Frageee.de, welches mit der Open Source Software Question2Answer betrieben wird, habe ich ein kleines PHP Skript geschrieben, was dafür sorgt, dass alle bereits gestellten Fragen im Google Index landen.
Ohne Sitemap wurden bei uns nur circa 50-60% Fragen zeitnah indiziert.
Die Datei muss in das Root Verzeichniss eurer Question2Answer Installation kopiert werden und die Zeile $urlpath=”http://frageee.de/” muss angepasst werden.
Danach muss die Sitemap in den Google Webmaster Tools eingereicht werden.
Wichtig:Zum Kopieren erst einmal auf “view plain” klicken, WordPress zerschiesst teilweise den Code bei der Ausgabe.
English:
- Copy the code (click on view plain first) to your question2answer root directory as sitemap.php.
- Change “http://frageee.de” to your Site URL.
- Log into Google Webmasters Tools and add the sitemap URL.
$urlpath="http://frageee.de/";
include "qa-config.php";
define("QA_BASE_DIR", dirname(empty($_SERVER["SCRIPT_FILENAME"]) ? __FILE__ : $_SERVER["SCRIPT_FILENAME"])."/");
require_once "qa-include/qa-base.php";
error_reporting('E_NONE');
echo '
'.$urlpath.'
2010-05-03T19:59:46+00:00
daily
1.0
';
mysql_connect("localhost",QA_MYSQL_USERNAME,QA_MYSQL_PASSWORD);
@mysql_select_db(QA_MYSQL_DATABASE) or die( "Unable to select database");
if ($_GET["all"] == "1") $getAll = 1;
else $getAll = 0;
$query = "select postid, type, parentid, title, content, created from qa_posts where (type = 'Q') order by created desc";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i = 0;
while ($i < $num)
{
$postId = mysql_result($result, $i, "postid");
$type = mysql_result($result, $i, "type");
$parentId = mysql_result($result, $i, "parentid");
$created = mysql_result($result, $i, "created");
$title = mysql_result($result, $i, "title");
#echo urlencode($title);
#$fields['url']=qa_path_html(qa_q_request($postId, $title));
#e#cho $fields['url'];
#echo utf8_encode($title);
#echo qa_q_request($postId , $title);
echo '
'.$urlpath.qa_q_request($postId , str_replace("&","%26",utf8_encode($title))).'
'.date("Y-m-d\TH:i:s+00:00",strtotime($created)).'
Daily
0.5
';
$i++;
}
echo '
';
?>
Related posts:

June 10th, 2010 on 10:37
error code http://www.sorular.tk/sitemap.php
————-
$urlpath=”http://www.sorular.tk/”; include “qa-config.php”; define(“QA_BASE_DIR”, dirname(empty($_SERVER["SCRIPT_FILENAME"]) ? __FILE__ : $_SERVER["SCRIPT_FILENAME"]).”/”); require_once “qa-include/qa-base.php”; echo ‘ ‘.$urlpath.’ 2010-05-03T19:59:46+00:00 daily 1.0 ‘; mysql_connect(QA_MYSQL_HOSTNAME,QA_MYSQL_USERNAME,QA_MYSQL_PASSWORD,QA_MYSQL_DATABASE); @mysql_select_db(QA_MYSQL_DATABASE) or die( “Unable to select database”); if ($_GET["all"] == “1″) $getAll = 1; else $getAll = 0; $query = “select postid, type, parentid, title, content, created from qa_posts where (type = ‘Q’) order by created desc”; $result = mysql_query($query); $num = mysql_numrows($result); $i = 0; while ($i < $num) { $postId = mysql_result($result, $i, "postid"); $type = mysql_result($result, $i, "type"); $parentId = mysql_result($result, $i, "parentid"); $created = mysql_result($result, $i, "created"); $title = mysql_result($result, $i, "title"); echo ' '.$urlpath.qa_q_request($postId , $title).' '.date("Y-m-d\TH:i:s+00:00",strtotime($created)).' Daily 0.5 '; $i++; } echo ' ';
June 10th, 2010 on 12:19
You forgot to add < ? at the beginning of sitemap.php and ?> at the end of sitemap.php
June 12th, 2010 on 20:45
http://www.sorular.tk/sitemap.php
i did its but website has error
June 12th, 2010 on 20:48
thanks, it is beatiful… No problem
June 26th, 2010 on 22:00
http://www.prepare4interview.com/sitemap.php
It is showing all urls with dates..
But when i submited this url to google webmaster got follwoing error:
Parsing error
We were unable to read your Sitemap. It may contain an entry we are unable to recognize. Please validate your Sitemap before resubmitting
What could be the reason..
Can we get html site map?
July 22nd, 2010 on 08:33
When i submited my sitemap to google webmaster got follwoing error: red cross in the Status column. Help me please
September 28th, 2010 on 15:01
Simon, thank You for the newest changes, the script now works for me. I finally just had to change line
1) adding <?php
15) mysql_connect(QA_MYSQL_HOSTNAME,QA_MYSQL_USERNAME,QA_MYSQL_PASSWORD);
as localhost did not work in my case
21) qa_posts to qa_myprefixposts
as my tableprefix is qa_myprefix
Other small issues I have mentioned in the q2a thread regarding the generator.
Vielen Dank nochmals, dass Du diesen generator geschrieben hast, für Nichtprogrammierer ist das eine riesige Hürde !!!
Gruss monk333
March 20th, 2011 on 05:13
Ich habe kein Problem mit der Sitemap, leider ein ganz anderes. Ich schaffe es nicht meine Seite in den Google Webmastertools anzumelden. Die HTMl Bestätigungsseite wird nicht erkannt: http://www.fragenschleuder/google34efdb438140ab5e.html
Eine Überprüfung mit Google Analytic s funktioniert auch nicht und wie man da den Metatag einbauen soll ist mir auch ein Rätsel. Vielleicht kann mir hier jemand einen Tipp geben.
May 25th, 2011 on 11:13
hey, is this working on 1.3+ ?