I was getting the same fatal error after creating a similar dynamic menu. What fixed the issue for me was redefining the default values:
$post->target="";
$post->attr_title="";
$post->description = '';
$post->classes="";
$post->xfn = '';
$post->status="publish";
$post->original_title="";
So your foreach loop would look like this:
foreach ( get_posts( $category_ten_last_posts ) as $post ) {
$post->menu_item_parent = $item->ID;
$post->post_type="nav_menu_item";
$post->object="header-lasts";
$post->type="header-lasts";
$post->menu_order = ++$menu_order;
$post->title = get_the_post_thumbnail( $post->ID ) . ' ' .$post->post_title;
$post->url = get_permalink( $post->ID );
$post->target="";
$post->attr_title="";
$post->description = '';
$post->classes="";
$post->xfn = '';
$post->status="publish";
$post->original_title="";
$child_items[]= $post;
}
Related Posts:
- WordPress Custom Post Types with a page as a parent?
- List All Custom Post Types Posts in Nav Menu Dynamically
- Custom post status not working
- How make get_next_post() return first post when viewing last one
- WP 3.1 – archive pages for custom content types possible now without a plugin?
- Admin Post Update Redirection to Posts Screen
- modify all posts of a category to “no comments allowed”
- How to not allow custom roles to edit published custom post types?
- Assign Page Template Within A Custom Post Type
- specify meta_key / meta_value condition for prev_post_link and next_post_link
- How to override parent theme function through the child theme [closed]
- Single Page WordPress CSS and JS links
- [Plugin: Posts 2 Posts] Changing display order of connections
- Disable dragging of metaboxes in custom post types?
- Error after deleting Custom Post Type with a function (no trash used)
- How to delete all posts from a custom post type?
- Structure for projects and clients
- adding .current* tags to custom post types and taxonomies
- How to get Custom Post ID by adding filter to child theme’s function
- Custom Post Type Alerts
- Remove All, Published and Trashed Post Views in Custom Post Type
- How to post twitter like updates on wordpress
- How to get all `supports` attributes by post type?
- Custom search for custom post meta with pre_get_posts interferes with WP search
- Weird problem happening with custom taxonmy when creating/updating posts
- Deleting Custom Post type data using mySQL command
- CPT: if more than X images are in post, use pagination
- How inefficient is it to use a Custom Post for 4-5 sentences & pull all to 1 page?
- Permalink structure by Post Meta value
- A question on creating filters for custom posts using taxonomy
- Conditional Query of Custom Post Type and custom taxonomy
- Showing up my custom post type in primary navigation
- 2 Templates 1 custom post type according url
- changing meta value and meta key of price field
- WordPress sort search results by custom order
- How to start a new post with custom Taxonomies already set?
- WooCommerce sort products by the actual product width(not the shipping width)
- Create a custom php page and load it at a specific slug
- Structure of data : CPT + terms
- How to remove post listing page for a custom post type
- Adding the_content() in custom template email
- Pages are not saving due to custom post type
- Migrating a taxonomy’s tags to the native category
- Losing Nav Active State in Menu
- custom post type vs. conditionally displaying meta boxes for specific terms?
- Edit the_content() function so to add a div wrapper
- Number of posts in the archive
- Ordering Submenu Pages in WP 3.1
- Replace dynamically content in a custom database table when a custom post is created
- How to customize work area / admin area in a custom post type without plugins?
- Move Genesis Single Page/Single Post Title
- Custom post type menu
- Custom post type’s posts are not showing anywere but in xml sitemap
- Only show columns in custom post type?
- How to get the current category with custom posts
- Display Custom Post Types Glossary
- How should I structure complex content hierarchies?
- Problems making shortcode with custom post types and taxonomy
- New posts label category with “new”
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- Function to add custom HTML into head in custom post-type list page
- What is the best way to manage small blocks of content on my home page?
- One post auto attached to many another items
- Can’t Get Parent and Child Categories of Custom Taxonomy to Display
- How do I “trash” a custom post type post while logged in as Admin
- WP 3.1 custom post type permlinks
- Placing Admin Post Metaboxes in Tabs
- Why is my custom post content only viewable when signed into WordPress?
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Prev/Next Navigation on Single Post Disappeared for Custom Post Type
- Is it possible to create 2 unique titles for an Events custom post type: Upcoming Events and Past Events?
- wp delete duplicate entries of custom post types every 15 minutes
- How to add custom supports for custom post types?
- Attempting to create custom “post” template, getting a 500 internal server error
- Adding a nav menu for a custom post type
- Post navigation doesn’t show (in custom template, custom post type, custom query)
- connect users to Custom post types
- Custom Pagination based on Custom Post Type
- Custom user roles
- Change Background Color For CPT Template
- One Post with different content, depending on a Page
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Custom Post Type
- Registering an optional custom post type from a plugin
- Calling the first & last post by category in custom post type
- Custom metabox value not saving
- Cannot modify a registered custom post type rewrite slug
- Add Excerpt On Quicksand Plugin
- Custom post type adding additional markup
- Select Menu for Custom post Type does not save
- Why is Posts page selected when showing single Custom Post Type?
- Navigation links to posts in current term shortcode
- Inserting two categories
- How to delete unnecessary custom post types in the UI
- Navigation won’t update to show full path to single post
- Advise on Custom Taxonomies and Structure
- cannot export data from CPT UI (books)
- REQUIRED: The theme uses the register_post_type() function, which is plugin-territory
- How to develop Knowledge center in WordPress Website