Title: [Plugin: Magic Fields] MF2 &#8211; Loop not working
Last modified: August 20, 2016

---

# [Plugin: Magic Fields] MF2 – Loop not working

 *  [Janick](https://wordpress.org/support/users/ace69/)
 * (@ace69)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-magic-fields-mf2-loop-not-working/)
 * Hi All,
 * I have created several custom post types with Magic fields 2, when creating an
   item I have attached it to a specific category.
 * When looking at the front end, the category widget indicates that there are posts
   under the categories.
    However when I want to display the posts from a specific
   category, I get the error:
 * “Nothing Found
    Apologies, but no results were found for the requested archive.
   Perhaps searching will help find a related post.”
 * Could someone indicated where I need to search or what I need to change in the
   loop?
 * Many thanks!

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

 *  Plugin Author [hunk](https://wordpress.org/support/users/hunk/)
 * (@hunk)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-magic-fields-mf2-loop-not-working/#post-2386611)
 * Do you use permalinks?
 * check without permalinks. tell me if works fine.
 *  Thread Starter [Janick](https://wordpress.org/support/users/ace69/)
 * (@ace69)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-magic-fields-mf2-loop-not-working/#post-2386616)
 * Thanks, the permalinks were not enable.
 * After some minor success programming myself I came across the code below.
    It
   adds all custom content types to the loop.
 * [http://bajada.net/2010/10/12/custom-post-types-in-the-loop-using-pre_get_posts-refined](http://bajada.net/2010/10/12/custom-post-types-in-the-loop-using-pre_get_posts-refined)
 *     ```
       function ucc_pre_get_posts_filter( $query ) {
         global $wp_query;
   
         if ( !is_preview() && !is_admin() && !is_singular() && !is_404() ) {
           if ($query->is_feed) {
           /* As always, handle your feed post types here. */
           } else {
             $my_post_type = get_query_var( 'post_type' );
             if ( empty( $my_post_type ) ) {
               $args = array(
                 'public' => true ,
                 '_builtin' => false
               );
               $output = 'names';
               $operator = 'and';
   
               /* Get all custom post types automatically. */
               $post_types = get_post_types( $args , $output , $operator );
               /* Or uncomment and edit to explicitly state which post types you want. */
               // $post_types = array( 'event' , 'location' );
   
               /* Add 'link' and/or 'page' to array() if you want these included:
                * array( 'post' , 'link' , 'page' ), etc.
                */
               $post_types = array_merge( $post_types , array( 'post' ) );
               $query->set( 'post_type' , $post_types );
             }
           }
         }
   
         return $query;
       }
       add_action( 'pre_get_posts' , 'ucc_pre_get_posts_filter' );
       ```
   

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

The topic ‘[Plugin: Magic Fields] MF2 – Loop not working’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/magic-fields.svg)
 * [Magic Fields](https://wordpress.org/plugins/magic-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/magic-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/magic-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/magic-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/magic-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/magic-fields/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * 2 replies
 * 2 participants
 * Last reply from: [Janick](https://wordpress.org/support/users/ace69/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-magic-fields-mf2-loop-not-working/#post-2386616)
 * Status: not resolved