blog & news + business profile ( companies ) both plugin
canonical not set.
I am modified my SEO plugin ( SEO PRO - Dis ) and now canonical issue solved both plugins.
Blog plugin sitemap generated but business profile no any option so companies urls cant add in any sitemap.
its affect in indexing & overall site seo.
Well, I try to make similar sitemap like blog for business profile plugin & generated successfully.
But sitemap has some issue.
Sitemap.php have below code - almost code done but little bug while adding companies url in sitemap array. pls check code & correct this error.
<?php
// MAKE SURE OSC_PLUGIN_PATH FUNCTION EXISTS
if( !function_exists('osc_plugin_path') ) {
function osc_plugin_path($file) {
$file = preg_replace('|/+|','/', str_replace('\\','/',$file));
$plugin_path = preg_replace('|/+|','/', str_replace('\\','/', PLUGINS_PATH));
$file = $plugin_path . preg_replace('#^.*oc-content\/plugins\/#','',$file);
return $file;
}
}
// GENERATE SITEMAP
function bpr_generate_sitemap() {
$start_time = microtime(true);
$seller = ModelBPR::newInstance()->getSellerByIdentifier($identifier);
//$locale = (Params::getParam('bprLocale') <> '' ? Params::getParam('bprLocale') : bpr_get_locale());
$locales = osc_get_locales();
$filename = osc_base_path() . 'sitemap-companies.xml';
@unlink($filename);
$start_xml = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . '<urlset xmlns="
https://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
file_put_contents($filename, $start_xml);
// INDEX
bpr_sitemap_add_url(osc_route_url('companies'), date('Y-m-d'), 'always');
// ADD Companies
if(count($seller) > 0) {
foreach($seller as $c) {
bpr_sitemap_add_url(osc_route_url('bpr-seller', array('identifier' => $seller['s_identifier'])), date('Y-m-d'), 'daily');
}
}
$end_xml = '</urlset>';
file_put_contents($filename, $end_xml, FILE_APPEND);
// PING SEARCH ENGINES
bpr_sitemap_ping_engines();
// CALCULATE GENERATION TIME
$time_elapsed = microtime(true) - $start_time;
return $time_elapsed;
}
// ADD URL TO SITEMAP - HELP FUNCTION
function bpr_sitemap_add_url($url = '', $date = '', $freq = 'daily') {
if( preg_match('|\?(.*)|', $url, $match) ) {
$sub_url = $match[1];
$param = explode('&', $sub_url);
foreach($param as &$p) {
list($key, $value) = explode('=', $p);
$p = $key . '=' . urlencode($value);
}
$sub_url = implode('&', $param);
$url = preg_replace('|\?.*|', '?' . $sub_url, $url);
} else {
$help = $url;
$help_encode = urlencode($help);
$help_fix = str_replace('%2C', ',', $help_encode);
$help_fix = str_replace('%2F', '/', $help_fix);
$help_fix = str_replace('%3A', ':', $help_fix);
$url = $help_fix;
}
$filename = osc_base_path() . 'sitemap-companies.xml';
$xml = ' <url>' . PHP_EOL;
$xml .= ' <loc>' . htmlentities($url, ENT_QUOTES, "UTF-8") . '</loc>' . PHP_EOL;
$xml .= ' <lastmod>' . $date . '</lastmod>' . PHP_EOL;
$xml .= ' <changefreq>' . $freq . '</changefreq>' . PHP_EOL;
$xml .= ' </url>' . PHP_EOL;
file_put_contents($filename, $xml, FILE_APPEND);
}
// PING SEARCH ENGINES WITH NEW SITEMAP - HELP FUNCTION
function bpr_sitemap_ping_engines() {
$sitemap = osc_base_url() . 'sitemap-companies.xml';
osc_doRequest( '
https://www.google.com/webmasters/sitemaps/ping?sitemap='.urlencode($sitemap), array());
osc_doRequest( '
https://www.bing.com/webmaster/ping.aspx?siteMap='.urlencode($sitemap), array());
osc_doRequest( '
https://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid='.osc_page_title().'&url='.urlencode($sitemap), array());
}
osc_add_hook('cron_daily', 'bpr_generate_sitemap');
?>
https://in.nearmeads.com/sitemap-companies.xml Output xml -
<urlset xmlns="
https://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc/>
<lastmod>2020-07-16</lastmod>
<changefreq>always</changefreq>
</url>
</urlset>