Submit WordPress Post URLs to Google When Publishing – WordPress Tutorial

By | June 15, 2019

You can submit your wordpress post sitemap to google by Google Ping when published a post, which can increate your site crawl rate.

Google Ping Service is:

How to submit your sitemap to google by google ping in wordpress?

Here is an example:

function submit_to_google(){
	$sitemap_url = '';
	$ping_url = "".esc_url($sitemap);
	$response = wp_remote_get($ping_url);
	if ( is_wp_error( $response ) ) {
	        $error_message = $response->get_error_message();
            echo "Something went wrong: $error_message";
	     } else {
function submit_urls($ID, $post){
add_action('publish_post', 'submit_urls', 10, 2 );

Then wordpress will notify google once you have published a post.

Leave a Reply

Your email address will not be published. Required fields are marked *