add menu page in loop menu order

Ok it took me a while, but I think I have it. I had to use usort. I also included the code for the get_top_level_pages() method. $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array(‘post_type’ => ‘page’, ‘posts_per_page’ => ‘-1’)); $top_level_pages = get_page_by_title(‘Locations’); $menuArray = get_page_children( $top_level_pages->ID, $all_wp_pages ); function compareOrder($a, $b) { return $a->menu_order – $b->menu_order; … Read more

no themes or editor under appearance menu

I would ensure that your user is an ‘admin’ type. Then I would reinstall WP core files (via the update, if that is available; otherwise you will have to do a selective file transfer so as to not to overwrite your settings). I would also rename the ‘plugins’ folder to ‘xxplugins’ temporarily, to ensure that … Read more

adding existing menu page on new customer user role

Okay, I give you an answer based on capabilities and not role. You’ll find a way to hide it for other role if you want (you have the code in your question). add_menu_page requires some parameters, hook and callback to work : https://developer.wordpress.org/reference/functions/add_menu_page/ // Here is your hook to add page to the menu add_action(‘admin_menu’, … Read more

Creating Admin Submenu Page via Class Method

the action admin_menu is called with one empty argument, then anonymous function can only be with 0 or 1 useless argument. and then if you want to pass variables to this function, you can try that : public function add_submenu_page( $title, $capability = ‘administrator’ ) { $post_type = self::uglify( $this->post_type_name ); $GLOBALS[“MyPlugin_menu”] = [ “post_type” … Read more

admin menu: use default “general” page for theme settings using add_menu_page and add_submenu_page

You need to create a submenu page with the same slug as the menu page. E.g. $menu_slug = “my_menu_slug”; $desired_capability = “manage_options”; //Or whatever you need $menu_page_callback = “menu_page_callback_function”; add_menu_page( “Page Title”, “Menu Title”, $desired_capability, $menu_slug, $menu_page_callback ); add_submenu_page( $menu_slug, “Submenu Page Title”, “Submenu Menu Title”, $desired_capability, $menu_slug, $menu_page_callback ); //Note, the 5th and 6th … Read more

Admin – Custom Post Type in WooCommerce menu – how to control menu order

menu_position is not used when you set show_in_menu to a submenu. to put your menu in last position there is 2 solutions. The first is to change the menu construction priority like this : add_action(“admin_menu”, function () { remove_action(‘admin_menu’, ‘_add_post_type_submenus’); add_action( ‘admin_menu’, ‘_add_post_type_submenus’, 200); // 200 to set it after the last element of WooCommerce … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)