• Hi there,
    I am in the process of setting up a WordPress installation that appears at two domains (i.e. https://example1.com and https://example2.com). I have managed to figure out how to switch the theme and the Site URL based on the SERVER_NAME. However, one of the few remaining problems is that links to existing content added by an user through the WYSIWYG editor still get the current site root added to them. So, if I am logged in to example1.com and add a link to an internal page through the “Existing Content” feature, “https://example1.com/” is appended to the beginning of the URL.

    So, my question is, how do I stop this behavior? I would really like internal links to be relative to the Site URL of the visitor, not the Site URL of the author.

    I have looked at two plugins (Relative URL and Root Relative URLs) and both of them are too broad. They change every URL on the site, which I don’t need.

    I’ve tried adding this to my functions.php, with no success:

    function my_mce_setup( $init_array ) {
    	$init_array['convert_urls'] = 'false';
    	$init_array['relative_urls'] = 'true';
    
    	return $init_array;
    }
    add_filter( 'tiny_mce_before_init', 'my_mce_setup' );

    I’m assuming I’m missing something about how Tiny MCE settings are passed…
    EDIT: I’m also not sure that the “Link to Existing Content” feature is even related to Tiny MCE.

    Before you reply, please understand that I already know that I’m stretching WordPress beyond what it is “intended” to do. I’m aware that WordPress is designed to only support absolute URLs, but I still need a solution.

    Thanks in advance for any help!

    -Justin

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m sorry no one responded to your question. I hope you’ve figured this out by now, and if so, it would very helpful if you posted a solution here. TIA.

    Were you also able to prevent relative links that happen to appear in excerpts from going 404 when followed from archive pages?

    Thread Starter justinmaurerdotdev

    (@360zen)

    You know what, the code I posted above actually DOES do what I was asking for. For some reason, when I posted this, I wasn’t seeing it working, but I am now.

    Your thought about excerpts or links showing elsewhere is a tricky one, but on the site I’m building right now, links don’t show in the excerpts so no problem there. Ideally, there would be a way to force these links to be relative to the root, so this wouldn’t be an issue. Right now they show up as “../page/post” or whatever. But, they SHOULD show the full path to that post (or whatever content is desired) “/path/page/post”.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to force Tiny_MCE links to be relative’ is closed to new replies.