Make Paths Relative

Make(convert) the absolute URLs(paths) to relative.

Author:YAS Global Team (profile at wordpress.org)
WordPress version required:3.5
WordPress version tested:6.0
Plugin version:1.3.0
Added to WordPress repository:16-06-2016
Last updated:25-05-2022
Rating, %:82
Rated by:15
Plugin URI:https://www.yasglobal.com/web-design-developm...
Total downloads:49 330
Active installs:4 000+
plugin download
Click to start download

This plugin can make(convert) the paths(URLs) to a relative instead of absolute. This plugin is useful for using relative URLs. The given below list of permalinks and src can be easily converted to a relative:

  • Post Permalinks
  • Archive Permalinks
  • Author Permalinks
  • Term Permalinks
  • Scripts Paths(src)
  • Styles Paths(src)
  • Image Paths(src)

All the above permalinks and src can be converted to a relative instead of absolute by using this plugin. You can select the options from the plugin settings page.

Filters

If you want to exclude some Permalink or src to be relative then you can use paths_relative filter in your theme’s functions.php or in your custom plugin.

Your filter may look like this (Below filter would make the jquery.js Path to absolute):

function yasglobal_change_path( $link ) {
  if( $link == '/wp-includes/js/jquery/jquery.js?ver=1.12.4' ) {
    $link = site_url().'/wp-includes/js/jquery/jquery.js?ver=1.12.4';
  }
  return $link;
}
add_filter( 'paths_relative', 'yasglobal_change_path' );

If you don’t want to Make the Paths relative for srcset(Responsive Images) then just add the below-mentioned line in your theme’s functions.php.

add_filter( 'srcset_paths_relative', '__return_false' );

If you want to make plugin works and all the paths relative without going to check/visit Settings Page so, just add this line in your theme’s functions.php.

add_filter( 'make_paths_relative_activate_all', '__return_true' );

Make sure to check the settings Page

Thanks for the Support

The support from the users that love Make Paths Relative is huge. You can support Make Paths Relative future development and help to make it even better by giving a 5-star rating with a nice message to me ????

Bug reports

Bug reports for Make Paths Relative are welcomed on GitHub. Please note GitHub is not a support forum, and issues that aren’t properly qualified as bugs will be closed.