Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter swarajaccustra

    (@swarajaccustra)

    Thanks, worked. looking for the next stable update. Great plugin btw.

    Thread Starter swarajaccustra

    (@swarajaccustra)

    I’ve created a custom page template (page-custom.php)

    <?php
    /*
    Template Name: Custom Page Template
    */

    get_header();

    $id = get_the_ID();

    //print_r($id);

    $fields = get_fields($id);

    print_r($fields);

    get_footer();
    ?>

    In ACF I’ve two custom field groups.

    In “Custom Fields” Group, I’ve a text field called “Location”.
    In “General” Group, I’ve a galerie 4 field called “Photo Gallery”.

    In Location, My input text is “India”.
    When I add images to Gallery field. I get both Location and Photo Gallery fields using get_fields() function. If there’s no image, I don’t get anything. Atleast, I should get the location field.

    Thread Starter swarajaccustra

    (@swarajaccustra)

    The problem is that there’s no error message, which makes it difficult to troubleshoot. If there are no images in the gallery, the entire get_fields() function stops working. I can’t simply skip the gallery field because get_fields() doesn’t return anything in that case. Ideally, it should at least return null so that I can detect the missing gallery field and handle it.

    How did I check this? By using WordPress’s default meta fields function, which returned the expected result.

    [my_field_key]=> Array
    (
    [0] => a:0:{}
    )

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