Support » Plugin: Multiple Domain » post img src and links are still going to the default site

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Gustavo Straube

    (@gustavostraube)

    Hello! The issue you’re facing is related to post content. The image URL is part of the post content and the plugin currently doesn’t filter post contents to replace URLs. I’m creating an issue in the plugin repository to add an option for that in a near future, you can follow the updates here: https://github.com/straube/multiple-domain/issues/22.

    In the meanwhile, you can add the filter yourself. If you have some basic programming skills, you should be able to open the “functions.php” file of your theme and append a couple lines of code to it:

    
    add_filter('the_content', 'fix_content_for_multiple_domain');
     
    function fix_content_for_multiple_domain($content)
    {
        if (defined('MULTPLE_DOMAIN_ORIGINAL_DOMAIN') && MULTPLE_DOMAIN_ORIGINAL_DOMAIN !== MULTPLE_DOMAIN_DOMAIN) {
            $regex = '/(https?:\/\/)' . preg_quote(MULTPLE_DOMAIN_ORIGINAL_DOMAIN) . '/i';
            $content = preg_replace($regex, '$1' . MULTPLE_DOMAIN_DOMAIN, $content);
        }
        return $content;
    }
    

    WARNING: before you go ahead and change your “functions.php” file, I strongly advise you to make a copy/back up of it. This way you can easily roll back the changes in case anything goes wrong.

    You may also refer to the WP reference on “the_content” filter: https://developer.wordpress.org/reference/hooks/the_content/

    Thread Starter nc_nc

    (@nc_nc)

    Thank you so much for the code. This worked nicely for the blog pages, but not for the json api call. Do you know what code controls these react json requests?

    I just found this plug-in that could fix this…

    Plugin Contributor Gustavo Straube

    (@gustavostraube)

    Hello,

    Sorry for the delayed response. I found a way to fix the JSON API calls but didn’t have a chance yet to update the plugin. I’ll do it as soon as I find some free time and keep you posted.

    Thanks for your patience.

    Plugin Contributor Gustavo Straube

    (@gustavostraube)

    Hello,

    I just released a new version (0.8.4) that fixes the post URL (guid) in JSON API responses. Please update the plugin in your WordPress instance and let me know if that fixes the issue.

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘post img src and links are still going to the default site’ is closed to new replies.