Skip to content

Instantly share code, notes, and snippets.

@mo3aser
Last active January 14, 2016 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mo3aser/c02c2125999c4bc3099f to your computer and use it in GitHub Desktop.
Save mo3aser/c02c2125999c4bc3099f to your computer and use it in GitHub Desktop.
How to modify the WordPress importer plugin to Import Menu Item's custom fields
<?php
# WordPress - Import Menu Item's custom fields
# By Fouad Badawy - TieLabs.com
#1- Edit wordpress-importer.php
#2 search for
$id = wp_update_nav_menu_item( $menu_id, 0, $args );
if ( $id && ! is_wp_error( $id ) )
$this->processed_menu_items[intval($item['post_id'])] = (int) $id;
#3- Replace it with
$id = wp_update_nav_menu_item( $menu_id, 0, $args );
if ( $id && ! is_wp_error( $id ) ) {
$this->processed_menu_items[intval($item['post_id'])] = (int) $id;
/* By Fouad Badawy ( TieLabs.com ) - Store The mega menu custom options */
$tie_menu_option = array( 'tie_megamenu_type', 'tie_megamenu_columns' );
foreach ( $item['postmeta'] as $meta ){
if( in_array( $meta[ 'key' ], $tie_menu_option ) && !empty( $meta[ 'value' ] ) ){
update_post_meta( intval($id) , $meta[ 'key' ], $meta[ 'value' ] );
}
}
}
#4- Change the value of $tie_menu_option in line 19 with your custom fields name
?>
@kidesigner
Copy link

You save my time. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment