Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Jan Koester

    (@dasmaeh)

    Thanks for reporting this.

    I’ve been almost sure to have ruled out all these query related problems but somehow it seems I still got it wrong. I will like into this asap.

    Could you please tell me what you mean by “portfolio”? I guess this is another plugin creating a custom post type.

    Thread Starter sunnydar

    (@sunnydar)

    My theme creates custom post type portfolio. I’m using the enfold theme if that’s relevant.

    Plugin Author Jan Koester

    (@dasmaeh)

    I won’t be able to test the plugin with your theme so I will need your help.
    Could you please try to replace the function query_recipes() in php/class/rpr_core.php line 192 and following by

    function query_recipes($query) {
    
    		// Don't change query on admin page
        	if (is_admin()){
        		return;
        	}
    
    		if ( ! is_admin() && $query->is_main_query() ) {
    
    			// Post archive page:
        		if ( is_post_type_archive( 'rpr_recipe' ) ) {
        			//set post type to only recipes
          			$query->set('post_type', 'rpr_recipe' );
    				return;
        		}
    
    			// All other pages:
    			// add post type to query
    			$post_type = $query->get('post_type');
                if( is_array( $post_type ) && ! array_key_exists( 'rpr_recipe', $post_type ) ){
                	$post_type[] = 'rpr_recipe';
                } else {
                	$post_type = array( 'post', 'rpr_recipe' );
                }
                $query->set( 'post_type', $post_type );
    			return;
    
      		}
         }

    This should solve the problem.

    Thread Starter sunnydar

    (@sunnydar)

    Unfortunately, that didn’t fix it. I still get the same problems.
    I can give you access to my development site if that would make things easier.

    Plugin Author Jan Koester

    (@dasmaeh)

    There still was a nasty bug in the patch I posted above. If the following code helps, all is well.

    function query_recipes($query) {
    
    		// Don't change query on admin page
        	if (is_admin()){
        		return;
        	}
    
    		if ( ! is_admin() && $query->is_main_query() ) {
    
    			// Post archive page:
        		if ( is_post_type_archive( 'rpr_recipe' ) ) {
        			//set post type to only recipes
          			$query->set('post_type', 'rpr_recipe' );
    				return;
        		}
    
    			// All other pages:
    			if( !is_page() ){
    				// add post type to query
    				$post_type = $query->get('post_type');
                	if( is_array( $post_type ) && ! array_key_exists( 'rpr_recipe', $post_type ) ){
                		$post_type[] = 'rpr_recipe';
                	} else {
                		$post_type = array( 'post', 'rpr_recipe' );
                	}
                	$query->set( 'post_type', $post_type );
    				return;
    			}
      		}

    If not access to your dev system could indeed be helpful. Please send me a private mail to [email protected]

    Thread Starter sunnydar

    (@sunnydar)

    Unfortunately, that didn’t fix it either. I just created an administrator with your email, so you should receive an email with the username and password for the developer site.

    Thanks for all your help!

    Thread Starter sunnydar

    (@sunnydar)

    For the developer site, when the plugin is activated, it breaks “portfolio item 1” under portfolio. When the plugin is deactivated, it starts working again.

    Plugin Author Jan Koester

    (@dasmaeh)

    Thanks for giving me access. However I still cannot clearly see the reason for the problem. And I cannot edit file which is probably causing all the problems from the backend.

    Could you please to 2 things for me:

    1. Comment line 39
      //add_action( 'pre_get_posts', array( $this, 'query_recipes' ) );

      in rpr_core.php, activate the plugin and see id the portfolio items are working. Recipes shouldn’t work then.

    2. Once again replace the function query_recipes by the following. I need to see how the query is changed.
      function query_recipes($query) {
      
      		// Don't change query on admin page
          	if (is_admin()){
          		return;
          	}
      
      		if ( ! is_admin() && $query->is_main_query() ) {
      
      			// Post archive page:
          		if ( is_post_type_archive( 'rpr_recipe' ) ) {
          			//set post type to only recipes
            			$query->set('post_type', 'rpr_recipe' );
      				return;
          		}
      
      			// All other pages:
      			if( !is_page() ){
      				var_dump($query);
      				// add post type to query
      				$post_type = $query->get('post_type');
                  	if( is_array( $post_type ) && ! array_key_exists( 'rpr_recipe', $post_type ) ){
                  		$post_type[] = 'rpr_recipe';
                  	} else {
                  		$post_type = array( 'post', 'rpr_recipe' );
                  	}
                  	$query->set( 'post_type', $post_type );
      				var_dump($query);
      				return;
      			}
        		}
          }

    Thanks for your help!

    Thread Starter sunnydar

    (@sunnydar)

    I did those. The portfolio item is working now.

    Plugin Author Jan Koester

    (@dasmaeh)

    Forgot to mention: Please remove the comment in line 39 again. Thanks.

    Thread Starter sunnydar

    (@sunnydar)

    That breaks it again.

    Plugin Author Jan Koester

    (@dasmaeh)

    Sure.
    Just to explain it:

    The function query_recipes manipulates the wp_query to add recipes as post_type to the query so recipes can be displayed in category listings, on the front page, etc.
    However this manipulation seems to throw out the portfolio post type. This shouldn’t happen though. I’ll now try to figure out how to avoid this. Therefore I will need the output of the two var_dump statements.

    Thread Starter sunnydar

    (@sunnydar)

    ok how do i get the output of the two var_dump statements.

    Plugin Author Jan Koester

    (@dasmaeh)

    Already got it. That’s why you should replace the function once again.

    Thread Starter sunnydar

    (@sunnydar)

    oh ok thanks

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Version .7 Breaks my portfolio items’ is closed to new replies.