Skip to content

Instantly share code, notes, and snippets.

@will83
Last active September 25, 2015 18:24
Show Gist options
  • Save will83/4ee275b51677d1974a66 to your computer and use it in GitHub Desktop.
Save will83/4ee275b51677d1974a66 to your computer and use it in GitHub Desktop.
Function to know if a menu item has children
<?php
function menu_item_has_children($id){
global $wpdb;
$myrows = $wpdb->get_results( "SELECT * FROM `wp_postmeta` WHERE `meta_key` LIKE '_menu_item_menu_item_parent' AND `meta_value` LIKE ".$id );
if(empty($myrows)) :
return false;
else :
return true;
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment