• Resolved nprior

    (@nprior)


    When I insert a Post Grid which for the time being returns no posts but it will in due course, I get this error message both when I open the post to edit it and at the top of the preview page:

    Invalid argument supplied for foreach() in …. block-post-grid/index.php

    When I set the grid so that it has entries error disappears.

    Having an empty grid is valid if you are about to start publishing articles in a new category. As soon as I publish article 2 the grid will have entries and I don’t want to have to remember to go back to article 1 to re-edit it!

Viewing 3 replies - 1 through 3 (of 3 total)
  • David Rhoden

    (@davidrhoden)

    I’m having the same error with Atomic Blocks Post Grid, but I do have posts present. They are custom posts. The custom posts type shows up in the list of available post sources in the Block Options, but the grid continues to say “No Posts Found”.

    I’m guessing I did something wrong when creating the custom post type.

    Here’s how it is configured:

    function create_post_type_project() {
      register_post_type( 'project',
        array(
          'labels' => array(
            'name' => __( 'Projects' ),
            'singular_name' => __( 'Project' ),
            'add_new' => __('Add new'),
            'add_new_item' => __('Add new project'),
            'view_item' => __('View project'),
            'edit_item' => __('Edit project'),
            'search_items' => __('Search projects'),
            'not_found' => __('Project not found'),
            'not_found_in_trash' => __('Project not found in Trash')
          ),
          'public' => true,
          'can_export' => true,
          'has_archive' => true,
          'show_in_nav_menus' => true,
          'show_in_rest' => true,
          'capability_type' => 'post',
          'publicly_queryable' => true,
          'query_var' => 'project',
                'supports' => array(
            'title','editor','thumbnail','custom-fields','page-attributes','post-formats','author',
        	),
        )
      );
    }
    add_action( 'init', 'create_post_type_project' );
    Plugin Author atomicblocks

    (@atomicblocks)

    Hi @nprior,

    There is a fix for this in the next version of the plugin, thanks for the heads up!

    Hi @davidrhoden,

    The post grid doesn’t support custom post types yet, just standard posts. That’s why you’re not seeing those posts.

    Thread Starter nprior

    (@nprior)

    Thanks – I’ll keep a look out for it!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Empty post grid error message’ is closed to new replies.