Version .7 Breaks my portfolio items
-
When I upgrade to the newest version all of my portfolio items return a 404 error. I tried updating the permalinks, but it doesn’t help. Deleting the plugin and reinstalling version 0.6.1 makes everything work again.
-
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.
My theme creates custom post type portfolio. I’m using the enfold theme if that’s relevant.
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 functionquery_recipes()in php/class/rpr_core.php line 192 and following byfunction 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.
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.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 jan.koester@cbjck.de
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!
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.
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:
- 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.
- 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!
I did those. The portfolio item is working now.
Forgot to mention: Please remove the comment in line 39 again. Thanks.
That breaks it again.
Sure.
Just to explain it:The function
query_recipesmanipulates 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.ok how do i get the output of the two var_dump statements.
Already got it. That’s why you should replace the function once again.
oh ok thanks
- Comment line 39
The topic ‘Version .7 Breaks my portfolio items’ is closed to new replies.