Support

Account

Home Forums Backend Issues (wp-admin) My Custom Field Deletes Itself… Reply To: My Custom Field Deletes Itself…

  • You need to reset the global post object after you run your custom query

    
    function numediaweb_custom_user_profile_fields($user) {
      $objektsave = array();
      $the_query = new WP_Query("post_type=immomakler_object&posts_per_page=-1&field=ids");    
      if ($the_query->have_posts()) {
        global $post; // not sure if you need this or not, try it with and without
        while ($the_query->have_posts()){
          $the_query->the_post();
           $save = get_the_ID();
           $objektsave = get_post_meta($save,'objektnr_extern',true);
           $objekt[] = $objektsave;
    
        }
        wp_reset_postdata();
      }
      return $objekt;
    }