Google site map

0
265
views

Time to write another XML file with php. Google site map. Google needs a sitemap to complete a more efficient index of your website now. – there is no longer an “add URL” button. Now there is “submit a site map”. It doesn’t respond straight away – but it does register the links contained in a formatted XML file.

sitemap.xml

Watch your $DBH = new PDO($hostDb, $user, $password);

date_default_timezone_set(‘America/New_York’);

But anyway: the format of the file is then this :

<?xml version="1.0" encoding="UTF-8"?>
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <loc>http://www.weedbox.net</loc>
  <lastmod>2019-05-22</lastmod>
  <changefreq>monthly</changefreq>
  <priority>0.8</priority>
</url>

<url>
<loc>http://weedbox.net/ads/wordpress/wordpress/index.php/2019/05/18/how-to-pray-to-the-son-of-god</loc>
<lastmod>2019-05-18T23:22:52-04:00</lastmod>
<changefreq>weekly</changefreq>
</url>

Create the time format once more:

echo date(‘c’, strtotime($result [“post_modified”]));

‘c’ prints a lot of things, but this as well as ‘c’

2019-05-18T23:22:52-04:00 is directly from the MySQL entry. – ideal. but no different than someone else’s problems.

$ids = array();
while($row = $PTH->fetch()) {                 
$ids[] = $row;     }     
foreach ($ids as list($a)) {  
       /// whatever           
}

If you make any mistakes … I wouldn’t be sure what to look for when selecting a plugin – because they have more complexity than functionality.

To view the full working example try: view-source:http://www.weedbox.net/site.html

Previous articleRear Brake(s)
Next articleHow to live like a snake in outer-space
sssquirrel has a website at: https://whereisxur.com/ - unless its raining or something -
SHARE

LEAVE A REPLY

Please enter your comment!
Please enter your name here