Title: 404 image permalinks
Last modified: August 22, 2016

---

# 404 image permalinks

 *  Resolved [sunnydar](https://wordpress.org/support/users/sunnydar/)
 * (@sunnydar)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/)
 * I just realized the broken image permalinks are back after the most recent update.
 * [https://wordpress.org/plugins/recipepress-reloaded/](https://wordpress.org/plugins/recipepress-reloaded/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Jan Koester](https://wordpress.org/support/users/dasmaeh/)
 * (@dasmaeh)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396075)
 * Please try inserting the following code in rpr_core.php line 200
 *     ```
       // Querying specific page (not set as home/posts page) or attachment
       			if(!$query->is_home()) {
                      if($query->get('page_id') !== 0 || $query->get('pagename') !== '' || $query->get('attachment_id') !== 0) {
                           return;
                       }
                   }
       ```
   
 *  Thread Starter [sunnydar](https://wordpress.org/support/users/sunnydar/)
 * (@sunnydar)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396092)
 * That didn’t fix it.
 *  Plugin Author [Jan Koester](https://wordpress.org/support/users/dasmaeh/)
 * (@dasmaeh)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396257)
 * I’m sorry I can’t reproduce this faulty behaviour on my testing system. Please
   provide some more information on your setup, permalink structure and versions.
 *  Thread Starter [sunnydar](https://wordpress.org/support/users/sunnydar/)
 * (@sunnydar)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396279)
 * permalinks structure: [http://thestandardblog.com/2014/10/sample-post/](http://thestandardblog.com/2014/10/sample-post/)
   
   wordpress version: 4.0 RP: Version 0.7.2
 *  Plugin Author [Jan Koester](https://wordpress.org/support/users/dasmaeh/)
 * (@dasmaeh)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396292)
 * Still can’t reproduce the error you seem to get. Embedding images in recipes 
   and posts works perfectly for me. Also linking those to the original file for
   a lightbox works.
 *  Thread Starter [sunnydar](https://wordpress.org/support/users/sunnydar/)
 * (@sunnydar)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396294)
 * Embedding images works fine. The lightboxes work fine. It’s just went I go to
   the attachment permalink page, I get a 404. All of the images are still showing
   up fine though.
 *  Plugin Author [Jan Koester](https://wordpress.org/support/users/dasmaeh/)
 * (@dasmaeh)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396295)
 * Alright, now I understood the problem. Below you can find the function query_recipes()
   that solves this issue. It will be in the next release.
 *     ```
       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() && ! is_attachment() ){
       				// 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', $post_type, 'rpr_recipe' );
                   	}
                   	$query->set( 'post_type', $post_type );
       				return;
       			}
         		}
           }
       ```
   
 *  Thread Starter [sunnydar](https://wordpress.org/support/users/sunnydar/)
 * (@sunnydar)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396297)
 * thank you.
    What file is the function query_recipes($query) in?
 *  Thread Starter [sunnydar](https://wordpress.org/support/users/sunnydar/)
 * (@sunnydar)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396304)
 * Found it. That fixed it. Thank you!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘404 image permalinks’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/recipepress-reloaded_c4dbbe.svg)
 * [RecipePress Reloaded](https://wordpress.org/plugins/recipepress-reloaded/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/recipepress-reloaded/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/recipepress-reloaded/)
 * [Active Topics](https://wordpress.org/support/plugin/recipepress-reloaded/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/recipepress-reloaded/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/recipepress-reloaded/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [sunnydar](https://wordpress.org/support/users/sunnydar/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/404-image-permalinks/#post-5396304)
 * Status: resolved