Support

Account

Home Forums Backend Issues (wp-admin) Post Object field returning no results in WP Admin Reply To: Post Object field returning no results in WP Admin

  • Hi there, any luck with this issue? I’m having exactly the same issue. I’ll share with you exactly what’s happening, in case it is of any help for anybody to clarify what’s the matter.

    In my case, I’m using the plugin Advanced Custom Fields PRO, version 6.3.12.

    On a client’s WordPress site, I have a custom theme that we have coded ourselves. The site is in two languages (EN/FI) and we use Polylang for the multilingual functionality.

    We have a CPT, ‘Resorts’, where there are many different ACF fields, two of which are Post Object fields. One of them fetches CPT posts called ‘Golf Courses’, which are fetched fine and matching the current language, and then we have the other Post Object field, ‘Price Tables’, which, for some unknown reason, only works in Finnish (FI). If I try to find posts of this type in English, it just says ‘The results could not be loaded’, and it fails to find any posts.

    I have confirmed that both CPTs ‘Golf Courses’ and ‘Price Tables’ are created exactly in the same way, both have translations in both languages, are correctly linked between each language, and that the Polylang settings are the same for both of them.

    Here is an extract from our ‘functions.php’ file, where we register the relevant CPTs:

    function custom_post_type(){
    //CPT RESORTS
    $labels = array(
    ‘name’ => _x(‘Resorts’, ‘Post Type General Name’, ‘enjoytraveltours’),
    ‘singular_name’ => _x(‘Resorts’, ‘Post Type Singular Name’, ‘enjoytraveltours’),
    ‘menu_name’ => __(‘Resorts’, ‘enjoytraveltours’),
    ‘parent_item_colon’ => __(‘Resort padre’, ‘enjoytraveltours’),
    ‘all_items’ => __(‘Todos los resorts’, ‘enjoytraveltours’),
    ‘view_item’ => __(‘Ver resort’, ‘enjoytraveltours’),
    ‘add_new_item’ => __(‘Añadir resort’, ‘enjoytraveltours’),
    ‘add_new’ => __(‘Añadir resort’, ‘enjoytraveltours’),
    ‘edit_item’ => __(‘Editar resort’, ‘enjoytraveltours’),
    ‘update_item’ => __(‘Actualizar resort’, ‘enjoytraveltours’),
    ‘search_items’ => __(‘Buscar resort’, ‘enjoytraveltours’),
    ‘not_found’ => __(‘No encontrado’, ‘enjoytraveltours’),
    ‘not_found_in_trash’ => __(‘No encontrado en la papelera’, ‘enjoytraveltours’),
    );
    $args = array(
    ‘label’ => __(‘Resorts’, ‘enjoytraveltours’),
    ‘description’ => __(‘resorts destacados’, ‘enjoytraveltours’),
    ‘labels’ => $labels,
    ‘supports’ => array(‘title’,’thumbnail’,’custom-fields’,’revisions’,’page-attributes’,’post-formats’),
    ‘hierarchical’ => true,
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘show_in_menu’ => true,
    ‘show_in_nav_menus’ => true,
    ‘show_in_admin_bar’ => true,
    ‘menu_position’ => 0,
    ‘can_export’ => true,
    ‘has_archive’ => true,
    ‘exclude_from_search’ => false,
    ‘publicly_queryable’ => true,
    ‘capability_type’ => ‘page’,
    ‘menu_icon’ => ‘dashicons-tag’,
    );
    register_post_type(‘resorts’, $args);

    //CPT GOLF COURSES
    $labels = array(
    ‘name’ => _x(‘Golf courses’, ‘Post Type General Name’, ‘enjoytraveltours’),
    ‘singular_name’ => _x(‘Golf courses’, ‘Post Type Singular Name’, ‘enjoytraveltours’),
    ‘menu_name’ => __(‘Golf courses’, ‘enjoytraveltours’),
    ‘parent_item_colon’ => __(‘Golf course padre’, ‘enjoytraveltours’),
    ‘all_items’ => __(‘Todos los Golf courses’, ‘enjoytraveltours’),
    ‘view_item’ => __(‘Ver golf course’, ‘enjoytraveltours’),
    ‘add_new_item’ => __(‘Añadir golf course’, ‘enjoytraveltours’),
    ‘add_new’ => __(‘Añadir golf course’, ‘enjoytraveltours’),
    ‘edit_item’ => __(‘Editar golf course’, ‘enjoytraveltours’),
    ‘update_item’ => __(‘Actualizar golf course’, ‘enjoytraveltours’),
    ‘search_items’ => __(‘Buscar golf course’, ‘enjoytraveltours’),
    ‘not_found’ => __(‘No encontrado’, ‘enjoytraveltours’),
    ‘not_found_in_trash’ => __(‘No encontrado en la papelera’, ‘enjoytraveltours’),
    );
    $args = array(
    ‘label’ => __(‘Golf courses’, ‘enjoytraveltours’),
    ‘description’ => __(‘Golf courses destacados’, ‘enjoytraveltours’),
    ‘labels’ => $labels,
    ‘supports’ => array(‘title’,’thumbnail’,’custom-fields’,’revisions’,’page-attributes’,’post-formats’),
    ‘hierarchical’ => false,
    ‘public’ => false,
    ‘show_ui’ => true,
    ‘show_in_menu’ => true,
    ‘show_in_nav_menus’ => true,
    ‘show_in_admin_bar’ => true,
    ‘menu_position’ => 0,
    ‘can_export’ => true,
    ‘has_archive’ => true,
    ‘exclude_from_search’ => false,
    ‘publicly_queryable’ => true,
    ‘capability_type’ => ‘page’,
    ‘menu_icon’ => ‘dashicons-tag’,
    );
    register_post_type(‘golf-courses’, $args);

    //CPT PRICE TABLES
    $labels = array(
    ‘name’ => _x(‘Price Tables’, ‘Post Type General Name’, ‘enjoytraveltours’),
    ‘singular_name’ => _x(‘Price Table’, ‘Post Type Singular Name’, ‘enjoytraveltours’),
    ‘menu_name’ => __(‘Price Tables’, ‘enjoytraveltours’),
    ‘parent_item_colon’ => __(‘Price Table padre’, ‘enjoytraveltours’),
    ‘all_items’ => __(‘Todos los Price Tables’, ‘enjoytraveltours’),
    ‘view_item’ => __(‘Ver Price Table’, ‘enjoytraveltours’),
    ‘add_new_item’ => __(‘Añadir Price Table’, ‘enjoytraveltours’),
    ‘add_new’ => __(‘Añadir Price Table’, ‘enjoytraveltours’),
    ‘edit_item’ => __(‘Editar Price Table’, ‘enjoytraveltours’),
    ‘update_item’ => __(‘Actualizar Price Table’, ‘enjoytraveltours’),
    ‘search_items’ => __(‘Buscar Price Table’, ‘enjoytraveltours’),
    ‘not_found’ => __(‘No encontrado’, ‘enjoytraveltours’),
    ‘not_found_in_trash’ => __(‘No encontrado en la papelera’, ‘enjoytraveltours’),
    );
    $args = array(
    ‘label’ => __(‘price-tables’, ‘enjoytraveltours’),
    ‘description’ => __(‘New Price Tables system for the Resort Offers’, ‘enjoytraveltours’),
    ‘labels’ => $labels,
    ‘supports’ => array(‘title’,’custom-fields’,’revisions’,’post-formats’),
    ‘hierarchical’ => false,
    ‘public’ => false,
    ‘show_ui’ => true,
    ‘show_in_menu’ => true,
    ‘show_in_nav_menus’ => true,
    ‘show_in_admin_bar’ => true,
    ‘menu_position’ => 5,
    ‘can_export’ => true,
    ‘has_archive’ => true,
    ‘exclude_from_search’ => false,
    ‘publicly_queryable’ => true,
    ‘capability_type’ => ‘post’,
    ‘menu_icon’ => ‘dashicons-editor-table’,
    );
    register_post_type(‘price-tables’, $args);
    }

    add_filter( ‘pll_get_post_types’, ‘add_cpt_to_pll’, 10, 2 );

    function add_cpt_to_pll( $post_types, $is_settings ) {
    $post_types[‘golf-courses’] = ‘golf-courses’;
    $post_types[‘price-tables’] = ‘price-tables’;
    return $post_types;
    }

    add_action(‘init’, ‘custom_post_type’, 0);

    The ‘Price Tables’ CPT is a Post Object field called ‘prices_new’, which is a child field of the Repeater ‘offers’, and this is the field that is only picking up one language. This is the only difference compared to the ‘golf_courses’ Post Object field, which, in contrast, DOES work in both languages.

    In case the database could have become corrupted, I tried eliminating the CPT ‘Price Tables’ and creating it again from scratch with a different name in the ‘register_post_type’ function, and created posts again in both languages, but it did exactly the same, it only works in Finnish (FI), and not in English (EN).

    Anybody, please let me know if this is a known issue or if I’m doing something wrong, or if you know of a way to fix this issue.

    Thanking you in advance.