Create Google Image Sitemap Using Mysql and PHP DOM

Hello friends once again i am here with a new article for creating google image sitemap using PHP. I was working for my website www.tellmequotes.com and i need a image sitemap so that i will create a XML sitemap and submit it to google. As all my images are coming form my website database and my website is having more than 5 Lakh pages. Its very tough to create a sitemap for that much data.

For creating the sitemap we have many options like free sitemap generator’s, Paid sitemap generators etc. But using paid is quite expensive so i thought to create a script which will create the sitemap for images using the mysql database.

I was having 3 tables which is having images so i thought to create a temporary table and save all the images URL to 1 table.

Below we have created the functions for creating 1 table from 3 tables and remove the sitemap file for update and empty the table at last.





Now we have the table with all the url’s and we will create the sitemap using the table.

Note – ONLY 1000 LINKS ARE ALLOWED IN 1 IMAGE SITEMAP.

Here is the final function which will create the sitemap. Here we are using the for loop but at last we are not using its value. In next tutorial we will explain that how we can create the sitemap if we are having more than 1000 Links. Hope you like my tutorial’s if you have any suggestion please comment below. Hope to see you in next tutorial :-) .

2 Comments

  1. Hi,

    I have the imagesitemap.php and index.php files from phpclasses.org

    How can I integrate this files into a wordpress installation.

    Do I have to add and action to functions.php to execute this files. Or just put this files somewhere?

    Thanks

Leave a Reply

Your email address will not be published.

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Shares