Ive efficiently added all posts (of a customized publish sort) to my wordpress menu utilizing this technique:Right here
The whole lot is working nice. Sadly once I view the customiser, I get the “crucial error on this web site” message, it exhibits up on the preview ache, the admin navigation is seen nevertheless.
That is what I’ve in my features file:
/**
* auto_child_page_menu
*/
/* Sub menu */
add_filter( 'wp_get_nav_menu_items', 'cpt_locations_filter', 12, 3 );
perform cpt_locations_filter( $objects, $menu, $args ) {
if ( is_admin() ) { return $objects; }
$child_items = array();
$menu_order = rely($objects);
$parent_item_id = 0;
foreach ( $objects as $merchandise ) {
if ( in_array('history-menu', $item->lessons) ){
$parent_item_id = $item->ID;
}
}
if($parent_item_id > 0){
foreach ( get_posts( 'post_type=historical past&numberposts=-1' ) as $publish ) {
$post->menu_item_parent = $parent_item_id;
$post->post_type="nav_menu_item";
$post->object="customized";
$post->sort="customized";
$post->menu_order = ++$menu_order;
$post->title = $post->post_title;
$post->url = get_permalink( $post->ID );
array_push($child_items, $publish); // If i remark out this line, the customiser returns as regular.
}
}
return array_merge( $objects, $child_items );
}
After I remark out the road containing array_push, the customiser will return as regular. Makes me consider it’s one thing to do with the child_items.
Anybody have any concepts how you’ll repair this?
Thanks