콘텐츠로 건너뛰기 사이드바로 건너뛰기

Open

Reported for: WPML 다국어 CMS 4.6.13

Topic Tags: Compatibility

Overview of the issue

When the Use directory for default language option is enabled in WPML, URL submissions to Bing from IndexNow or Rank Math SEO plugins fail, displaying an “Invalid URL” error.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

For IndexNow:

  • Open your theme’s functions.php file.
  • Add the following snippet:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    function bing_wpml_remove_homefilter() {
        if ( defined( 'REST_REQUEST' ) && REST_REQUEST && isset( $_SERVER['REQUEST_URI'] ) ) {
            $request_uri = $_SERVER['REQUEST_URI'];
            if ( strpos( $request_uri, 'submitUrl' ) !== false ||
                 strpos( $request_uri, 'allSubmissions' ) !== false ) {
                global $wp_filter;
                if ( isset( $wp_filter['home_url']->callbacks[-10] ) ) {
                    foreach ( $wp_filter['home_url']->callbacks[-10] as $key => $value ) {
                        if ( str_contains( $key, 'home_url_filter' ) ) {
                            remove_filter( 'home_url', $key, -10 );
                        }
                    }
                }
            }
        }
    }
     
    add_action( 'rest_api_init', 'bing_wpml_remove_homefilter' );

For Rank Math SEO:

  • Open your theme’s functions.php file.
  • Replace:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    function custom_remove_home_url_filter_on_cmb2_admin_init_for_rm_giapi() {
        if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && $_POST['action'] === 'rm_giapi' ) {
            global $wp_filter;
     
        if ( isset( $wp_filter['home_url']->callbacks[-10] ) ) {
                foreach ( $wp_filter['home_url']->callbacks[-10] as $key => $value ) {
                        if ( str_contains( $key, 'home_url_filter' ) ) {
                        remove_filter( 'home_url', $key, -10 );
                    }
                }
            }
        }
    }
    add_action( 'cmb2_admin_init', 'custom_remove_home_url_filter_on_cmb2_admin_init_for_rm_giapi' );

답글 남기기

주제에 충실하고 다른 사람들을 존중해 주세요. 이 게시물과 관련 없는 문제에 대해 도움이 필요하다면, 지원 포럼을 이용하여 채팅을 시작하거나 티켓을 제출하세요.

다음 태그를 사용할 수 있습니다:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>