WPML
状态
未解决
相关插件/主题
The Events Calendar
主题标签
Compatibility

问题概述

如果您正在使用The Events Calendar插件及其Integrate events in main blog loop功能,当向 URL 添加任何参数(example.com?foo=bar)时,您会发现根页面显示为空白。特别是当同时也启用 WPML 的为默认语言使用目录设置时,就会出现此问题。

临时解决方法

请在继续操作前,确保已对站点进行完整站点备份


  • 打开 …/wp-content/plugins/the-events-calendar/src/Tribe/Query.php 文件。

  • 找到第 577 行。

  • 将:
    	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;
    	}

  • 替换为:
    	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;
    	}

所有已知问题 →