WPML

Panoramica del problema

Se stai usando il plugin The Events Calendar e la sua funzionalità Integrate events in main blog loop, riscontrerai che la pagina radice appare vuota quando viene aggiunto un parametro qualsiasi all’URL (example.com?foo=bar). Questo problema si verifica in particolare quando è abilitata anche l’impostazione Usa la directory per la lingua predefinita di WPML.

Soluzione alternativa

Assicurati di avere un backup completo del tuo sito prima di procedere.

  • Apri il file …/wp-content/plugins/the-events-calendar/src/Tribe/Query.php.
  • Cerca la riga 577.
  • Sostituisci:
    protected static function add_post_type_to_query( WP_Query $query, string ...$post_types ): void {
    
    	$query_post_types = self::get_query_post_types( $query );
    
    	$updated_post_types = array_unique( array_merge( $post_types, $query_post_types ) );
    
    	$query->set( 'post_type', $updated_post_types );
    	$query->query['post_type'] = $updated_post_types;
    }
  • Con:
    protected static function add_post_type_to_query( WP_Query $query, string ...$post_types ): void {
    
    	$query_post_types = self::get_query_post_types( $query );
    
    	// WPML Workaround for compsupp-7426
    	if ( class_exists('Sitepress') ) {
    		$is_root_enabled = apply_filters( 'wpml_sub_setting', false, 'urls', 'directory_for_default_language' );
    
    		if ( $is_root_enabled && is_home() ) {
    			return;
    		}
    	}
    
    	$updated_post_types = array_unique( array_merge( $post_types, $query_post_types ) );
    
    	$query->set( 'post_type', $updated_post_types );
    	$query->query['post_type'] = $updated_post_types;
    }

Tutti i problemi noti