Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change https to http urls in Yoast SEO
<?php
/**
* Plugin Name: Open Graph URLs for facebook
* Plugin URI: https://shubhampandey.in/migrating-website-http-https/
* Description: Change all your https url to http for facebook for Yoast SEO
* Author: Shubham Pandey
* Version: 1.0.0
* Author URI: https://shubhampandey.in
* License: GPL2+
*
* @package CustomURLs
*/
/**
* Function replaces https to http in urls
*
* @param string $url url link for replacing
**/
function spx_change_https( $url ) {
return str_replace( 'https://', 'http://', $url );
}
// Filter for open graph url.
add_filter( 'wpseo_opengraph_url', 'spx_change_https' );
// Filter for canonical url.
add_filter( 'wpseo_canonical', 'spx_change_https' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment