Support » Plugin: Multiple Domain Mapping on Single Site » Relative links fix

  • I think it will be useful to make links relative.
    Works with Woocommerce too.

    It will change your links in whole website:
    from:
    https://example.com/category/post-name/

    to:
    /category/post-name/

    In your active template folder in functions.php add this code:

    $filters = array(
    ‘post_link’, // Normal post link
    ‘post_type_link’, // Custom post type link
    ‘page_link’, // Page link
    ‘attachment_link’, // Attachment link
    ‘get_shortlink’, // Shortlink

    ‘post_type_archive_link’, // Post type archive link
    ‘get_pagenum_link’, // Paginated link
    ‘get_comments_pagenum_link’, // Paginated comment link

    ‘term_link’, // Term link, including category, tag
    ‘search_link’, // Search link

    ‘day_link’, // Date archive link
    ‘month_link’,
    ‘year_link’,

    ‘esc_url’, // Woocommerce
    );

    foreach ( $filters as $filter ) {
    add_filter( $filter, ‘wp_make_link_relative’ );
    }

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.