WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Conditional Content
Logical operators (2 posts)

  1. Kerfred
    Member
    Posted 1 year ago #

    Hi,

    Are you using other logical operators than "equals"?
    The "is not equal" operator would be very useful.

    Thanks for this very useful plugin.

    https://wordpress.org/plugins/wp-conditional-content/

  2. dame22
    Member
    Posted 2 months ago #

    I found a solution to this problem.

    Modify your class-core.php file on around line 74. Change the whole condition_query_string to:

    private function condition_query_string( $value, $match ) {
    	if( strstr( $value, ':' ) ){
    		list( $qs_key, $qs_value ) = explode( ':', $value );
    
    		$match = ( empty( $match ) ) ? 'exact' : $match;
    
    		# Check if GET value matches given value
    		if ( ! isset( $_GET[ $qs_key ] ) || false === $this->check_value( $_GET[ $qs_key ], $qs_value, $match ) )
    			return false;
    
    		return true;
    	}
    	elseif( strstr( $value, '!' ) ){
    		list( $qs_key, $qs_value ) = explode( '!', $value );
    
    		$match = ( empty( $match ) ) ? 'exact' : $match;
    
    		# Check if GET value doesn't match given value
    		if ( ! isset( $_GET[ $qs_key ] ) || false === $this->check_value( $_GET[ $qs_key ], $qs_value, $match ) )
    			return true;
    
    		return false;
    	}
    	else{
    		return false;
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.