WordPress.org

Ready to get started?Download WordPress

Forums

Invalid argument supplied for foreach() (7 posts)

  1. gaberosser
    Member
    Posted 2 years ago #

    I'm getting the following error in the admin area & front-end of my site:

    Warning: Invalid argument supplied for foreach() in /home/content/a/s/c/path/to/server/website/blah/wp-includes/post.php on line 1035

    I recently changed the FTP URL & got the site working, all except for this error. I have tried updating WP (3.2.1) & that didn't help. Now, the error only goes away when I swap themes.

  2. gaberosser
    Member
    Posted 2 years ago #

    I just narrowed this down further to my Custom Post Type in functions.php. Apparently it doesn't like this?

    add_action( 'init', 'register_cpt_feature' );
    
    function register_cpt_feature() {
    
        $labels = array(
            'name' => _x( 'Features', 'feature' ),
            'singular_name' => _x( 'Feature', 'feature' ),
            'add_new' => _x( 'Add New', 'feature' ),
            'add_new_item' => _x( 'Add New Feature', 'feature' ),
            'edit_item' => _x( 'Edit Feature', 'feature' ),
            'new_item' => _x( 'New Feature', 'feature' ),
            'view_item' => _x( 'View Feature', 'feature' ),
            'search_items' => _x( 'Search Features', 'feature' ),
            'not_found' => _x( 'No features found', 'feature' ),
            'not_found_in_trash' => _x( 'No features found in Trash', 'feature' ),
            'parent_item_colon' => _x( 'Parent Feature:', 'feature' ),
            'menu_name' => _x( 'Billboard', 'feature' ),
        );
    
        $args = array(
            'labels' => $labels,
            'hierarchical' => false,
            'description' => '4-at-a-time Rotating Feature Billboard',
            'supports' => array( 'title', 'thumbnail', 'page-attributes', 'custom-fields' ),
            'taxonomies' => false,
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'menu_position' => 5,
            'show_in_nav_menus' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => true,
            'has_archive' => false,
            'query_var' => true,
            'can_export' => true,
            'rewrite' => false,
            'capability_type' => 'page'
        );
    
        register_post_type( 'feature', $args );
    }

    I feel like the more I discover, the less I know.

  3. WebEndev
    Member
    Posted 2 years ago #

    I'm having the same problem exactly.

    Did you find a solution?

  4. Dennis Pedrie
    Member
    Posted 2 years ago #

    It seems to happen when the 'taxonomies' arg is set. Any luck fixing this?

  5. jmeher
    Member
    Posted 2 years ago #

    Same here, when 'taxonomies' are set? The question is do I need to have these taxonomies set for them to work if I register them for my custom post type? I guess I will find out but would like to know if something ever comes of this.

  6. AngelEyes
    Member
    Posted 2 years ago #

    hmm.. just got this when i tried to set taxonomies as well. I have my taxonomy registered properly and everything..

  7. Dennis Pedrie
    Member
    Posted 2 years ago #

    Pass the value as an array.

    i.e. array('post_tag', 'categories')

Topic Closed

This topic has been closed to new replies.

About this Topic