Add custom post type as submenu

I have a custom post type called ‘Movies‘ that I want to add under WooCommerce menu after "Extensions" as you can see below:

enter image description here

The WooCommerce page URL is /wp-admin/admin.php?page=wc-admin

I tried:

register_post_type( 'movie', array(     'show_in_menu' => 'admin.php?page=wc-admin' ) ); 

but that didn’t work. I am able to set Movies under Tools, Settings, Post, etc everywhere else, just not inside WooCommerce. Any ideas why?

Dropdown Submenu

Can someone please help. My webmaster has been busted for a DUI and I'm trying to learn but finding it a much more difficult than i anticipated. I'm ok with the basics but having issues with trying to incorporate a submenu opening to the right side of my dropdown menu. Can anyone please give me some help to incorporate this submenu into the dropdown. I'm trying hard but just having major issues. If someone could please help I would be much appreciative. I have searched the forum but not…

Dropdown Submenu

insert an HTML element if there is a submenu only

I am trying to insert an HTML element "an arrow or a checkbox" to make use of the "checkbox technique" so I can use it to expand the submenu "only if submenu is there" when checked. my question is: how to insert this HTML element if there is a "sub-menu" class only or only when the list < li> has a class "menu-item-has-children" then insert this HTML element.

I have tried to hook on 2 filters: nav_menu_css_class and wp_nav_menu_items but didn’t succeed.

I have also tried to add this element when calling the menu:

wp_nav_menu(array(  'theme_location' => 'main-menu',  'depth'          => 0,  'menu_class'     => 'topNav-List',  'menu_id'        => 'topNL',  'after'          => ' <label for="dropDown" class="btn-dropdown"></label>                        <input class="dropdown-open" type="checkbox" id="dropDown"/>                        <label for="dropDown" class="dropdown-overlay"></label>' )); 

but it will add this checkbox to all list items, which I don’t want at all.

WordPress add page under admin submenu and retaining the active status of the parent submenu page in the menu

I have added a page in the admin menu(pxmag-menu) and a submenu(pxmag-plans). There is another page(pxmag-plans-edit) set under the submenu(pxmag-plans) as the parent page.

public function __construct() {     require('pxMagAdminPlans.class.php');     $  this->admPlanObj= new pxMagAdminPlans();      add_action('admin_menu', array($  this, 'add_plan_admin_menu')); }  public function add_plan_admin_menu() {     add_menu_page(__('Dashboard', 'textdomain'), get_bloginfo('name'), 'manage_options', 'pxmag-menu', array($  this, 'pxmag_dash'), 'dashicons-welcome-view-site', 6);              add_submenu_page('pxmag-menu', __('Subscription Plans', 'textdomain'), 'Plans', 'manage_options', 'pxmag-plans', array($  this->admPlanObj, 'plan_admin_menu_page'));     add_submenu_page('pxmag-plans', __('Add/edit Plans', 'textdomain'), 'Add/edit plans', 'manage_options', 'pxmag-plans-edit', array($  this->admPlanObj, 'plan_admin_menu_edit')); } 

All the menu and submenu pages load fine.

But, when I open this page(pxmag-plans-edit), the menu selection in the WordPress admin shows nothing as current item, whereas the pxmag-plans is supposed to be the current selection.

(It is supposed to work like: when I click ‘Posts > Categories‘ and subsequently open the ‘edit category‘ page, the ‘Posts > Categories‘ option in menu keeps selected).

What is going wrong? What is the correct process?

How do I code access to the built-in UI of a CPT when it’s placed as submenu of another CPT that is protected by role?

I am toying around with WordPress capabilities, and having some difficulty understanding where I am going wrong. Right now, I have an admin menu that appears for all administrators with STUDENTS as a submenu of SCHOOL: each of those link to (When the user is in the HEADMASTER role, the link to the built-in UI for TEACHER appears and SCHOOL mimics its link). So far, all is well.

The bump in the road is when a non-HEADMASTER administrator clicks either SCHOOL or STUDENTS, the error “Sorry, you are not allowed to access this page” appears. (As expected, when that same admin accesses, the errors “You need a higher level of permission” and “Sorry, you are not allowed to edit posts in this post type” appear.) The issue is that the STUDENTS built-in UI is not accessible to all administrators. (As expected, there are no problems for HEADMASTERs.) How can this be resolved in such a way as to give all site admins access to STUDENTS and only HEADMASTERs access to TEACHERS while at the same time preserving the layout and functionality of the admin menu and built-in UI?

What I’ve Tried: When the 'show_in_menu' => 'edit.php?post_type=teacher' line is removed from the STUDENTS CPT, everything works as expected but STUDENTS becomes a top-level menu item instead of SCHOOL. I tried putting TEACHERS as a sub-menu item as STUDENTS, but SCHOOL does not change its link when the user is in the HEADMASTER role (also the ordering of TEACHERS and STUDENTS is backwards). I also tried add_menu_page() for SCHOOL and adding the slug returned for the show_in_menu argument of the TEACHERS and STUDENTS register_post_type args, respectively, but that didn’t work because it created a page instead of forwarding to the appropriate built-in UI.

 class School {     public static function init() {         add_action('init', array(__CLASS__, 'register_cpt'));         add_action('init', array(__CLASS__, 'add_role'));         add_action('admin_menu', array(__CLASS__, 'modify_menu'));     }      public static function register_cpt() {         register_post_type('teacher', array(             'labels' => array(                 'name'          => __('TEACHER'),                 'all_items'     => __('TEACHERS'),                 'menu_name'     => __('SCHOOL'),             ),             'show_ui'           => TRUE,             'capability_type'   => 'educator',             'map_meta_cap'      => TRUE,         ));         register_post_type('student', array(             'labels' => array(                 'name'          => __('STUDENT'),                 'menu_name'     => __('STUDENTS'),             ),             'show_ui'           => TRUE,             'show_in_menu'      => 'edit.php?post_type=teacher',         ));     }      public static function add_role() {         if(get_role('headmaster') === NULL) {             $  caps = array();             foreach(get_role('administrator')->capabilities as $  cap => $  tmp) {                 $  pos = strpos($  cap, 'post');                 if($  pos !== FALSE) {                     $  cap = str_replace('post', 'educator', $  cap);                     $  caps[$  cap] = TRUE;                 }             }             add_role('headmaster', 'HEADMASTER', $  caps);         }     }      public static function modify_menu() {         global $  submenu;         unset($  submenu['edit.php?post_type=teacher'][10]);     } } School::init(); 

Making submenu expand on click

I was able to solve it I am trying to have my "about" and "rooms" dropdown to be able to only expand when clicked on and displaying a small arrow similar in their "Info For" dropdown. When tabbing through it can work as is.

Also I noticed that in when tabbing through the menu and tabbing backwards (shift+tab) it dosnt go back up the dropdown why is that? Another issue is when I shrink the window to display the quick menu and tabbing through the menu it skips the…

Making submenu expand on click

Mostrar Submenu y ocultar cuando se hace click en otro Submenu

Estoy intentando mostrar un submenu cuando se hace click en un item y que cuando le de click a otro Submenu este se debe ocultar y mostrar el Submenu del item que di click y ademas de eso debe eliminar las clase que se agrega llamada open y añadirla al item que di click, de igual manera si le doy click a un item y le vuelvo a dar click a ese mismo item, debe ocultar el submenu, pero no he podido lograrlo, tengo el siguiente código

$  (".subtitle .action").click(function(event){  $  (this).parents(".subtitle").toggleClass("open");  $  (this).parents(".subtitle").find(".submenu").slideToggle("slow");      $  (this).parents(".subtitle").find(".submenu").toggleClass("opacity");  return false; });
<!DOCTYPE html> <html> <head> 	<title>Test</title> 	<style type="text/css"> 		.submenu { 			display: none; 		} 		.opacity { 			opacity: 0.5; 		} 	</style> </head> <body> 	<ul> 		<li class="subtitle"> 			<a href="#" class="action">Inicio</a> 			<ul class="submenu"> 				<li> 					<a href="#">Inicio 1</a> 				</li> 				<li> 					<a href="#">Inicio 2</a> 				</li> 				<li> 					<a href="#">Inicio 3</a> 				</li> 			</ul> 		</li> 		<li class="subtitle"> 			<a href="#" class="action">Nosotros</a> 			<ul class="submenu"> 				<li> 					<a href="#">Nosotros 1</a> 				</li> 				<li> 					<a href="#">Nosotros 2</a> 				</li> 				<li> 					<a href="#">Nosotros 3</a> 				</li> 			</ul>  		</li> 		<li class="subtitle"> 			<a href="#" class="action">Contacto</a> 			<ul class="submenu"> 				<li> 					<a href="#">Contacto 1</a> 				</li> 				<li> 					<a href="#">Contacto 2</a> 				</li> 				<li> 					<a href="#">Contacto 3</a> 				</li> 			</ul> 		</li> 		<li class="subtitle"> 			<a href="#" class="action">Empresa</a> 			<ul class="submenu"> 				<li> 					<a href="#">Empresa 1</a> 				</li> 				<li> 					<a href="#">Empresa 2</a> 				</li> 				<li> 					<a href="#">Empresa 3</a> 				</li> 			</ul> 		</li> 	</ul> 	<script src=""></script> </body> </html>

How can I include a option submenu page on my custom post type menu?

I have this custom post type:

// Register Custom Post Type Marca function create_banner_cpt() {     $  labels = array(         'name' => _x( 'Banner', 'Post Type General Name', 'sc-slider' ),         'singular_name' => _x( 'Banner', 'Post Type Singular Name', 'sc-slider' ),         'menu_name' => _x( 'Banner', 'Admin Menu text', 'sc-slider' ),         'name_admin_bar' => _x( 'Banner', 'Add New on Toolbar', 'sc-slider' ),         'archives' => __( 'Arquivos de banner', 'sc-slider' ),         'attributes' => __( 'Atributos de banner', 'sc-slider' ),         'parent_item_colon' => __( 'Slide anterior:', 'sc-slider' ),         'all_items' => __( 'Todos os slides', 'sc-slider' ),         'add_new_item' => __( 'Adicionar novo slide', 'sc-slider' ),         'add_new' => __( 'Adicionar novo', 'sc-slider' ),         'new_item' => __( 'Novo slide', 'sc-slider' ),         'edit_item' => __( 'Editar slide', 'sc-slider' ),         'update_item' => __( 'Atualizar slide', 'sc-slider' ),         'view_item' => __( 'Ver slide', 'sc-slider' ),         'view_items' => __( 'Ver slide', 'sc-slider' ),         'search_items' => __( 'Procurar slide', 'sc-slider' ),         'not_found' => __( 'Nenhum slide encontrado', 'sc-slider' ),         'not_found_in_trash' => __( 'Nenhum slide encontrado na lixeira', 'sc-slider' ),         'featured_image' => __( 'Inserir imagem no slide', 'sc-slider' ),         'set_featured_image' => __( 'Definir imagem do slide', 'sc-slider' ),         'remove_featured_image' => __( 'Remover imagem do slide', 'sc-slider' ),         'use_featured_image' => __( 'Usar como imagem do slide', 'sc-slider' ),         'insert_into_item' => __( 'Inserir no slide', 'sc-slider' ),         'uploaded_to_this_item' => __( 'Atualizar no slide', 'sc-slider' ),         'items_list' => __( 'Lista de slides', 'sc-slider' ),         'items_list_navigation' => __( 'Navegar na lista de slides', 'sc-slider' ),         'filter_items_list' => __( 'Filtrar lista de slides', 'sc-slider' ),     );     $  args = array(         'label' => __( 'Banner', 'sc-slider' ),         'description' => __( 'Banner rotativo', 'sc-slider' ),         'labels' => $  labels,         'menu_icon' => 'dashicons-welcome-write-blog',         'supports' => array('title', 'editor', 'thumbnail'),         'taxonomies' => array(),         'public' => true,         'show_ui' => true,         'show_in_menu' => true,         'menu_position' => 25,         'show_in_admin_bar' => true,         'show_in_nav_menus' => false,         'can_export' => false,         'has_archive' => false,         'hierarchical' => false,         'exclude_from_search' => true,         'show_in_rest' => true,         'publicly_queryable' => false,         'capability_type' => 'post',     );     register_post_type( 'sc-slider', $  args ); } add_action( 'init', 'create_banner_cpt', 0 ); 

I wanna include this option page:

// Settings Page: Configurar banner class configuraes_Settings_Page {      public function __construct() {         add_action( 'admin_menu', array( $  this, 'wph_create_settings' ) );         add_action( 'admin_init', array( $  this, 'wph_setup_sections' ) );         add_action( 'admin_init', array( $  this, 'wph_setup_fields' ) );     }      public function wph_create_settings() {         $  page_parent = 'edit.php?post_type=sc-slider';         $  page_title = 'Configurações do banner';         $  menu_title = 'Configurar banner';         $  capability = 'manage_banner_options';         $  slug = 'configuraes';         $  callback = array($  this, 'wph_settings_content');         add_submenu_page($  page_parent, $  page_title, $  menu_title, $  capability, $  slug, $  callback);     }      public function wph_settings_content() { ?>         <div class="wrap">             <h1>Configurações do banner</h1>             <?php settings_errors(); ?>             <form method="POST" action="options.php">                 <?php                     settings_fields( 'configuraes' );                     do_settings_sections( 'configuraes' );                     submit_button();                 ?>             </form>         </div> <?php     }      public function wph_setup_sections() {         add_settings_section( 'configuraes_section', 'Atenção: As funções a seguir estarão sujeitas a disponibilidade do tema.', array(), 'configuraes' );     }      public function wph_setup_fields() {         $  fields = array(             array(                 'label' => 'Efeito de transição',                 'id' => 'sc_slider_transition',                 'type' => 'radio',                 'section' => 'configuraes_section',                 'options' => array(                     'fade' => 'fade',                     'fadeout' => 'fadeout',                     'scrollHorz' => 'scrollHorz',                     'none' => 'none',                 ),             ),             array(                 'label' => 'Altura do banner',                 'id' => 'sc_slider_height',                 'type' => 'select',                 'section' => 'configuraes_section',                 'options' => array(                     '400 px' => '400 px',                     '500 px' => '500 px',                     '800 px' => '800 px',                     '100%' => '100%',                 ),             ),             array(                 'label' => 'Mostrar paginação',                 'id' => 'sc_slider_pager',                 'type' => 'radio',                 'section' => 'configuraes_section',                 'options' => array(                     'Sim' => 'Sim',                     'Não' => 'Não',                 ),             ),             array(                 'label' => 'Estilo da paginação',                 'id' => 'sc_slider_pager_template',                 'type' => 'select',                 'section' => 'configuraes_section',                 'options' => array(                     'Números' => 'Números',                     'Pontos' => 'Pontos',                 ),             ),             array(                 'label' => 'Velocidade das transições',                 'id' => 'sc_slider_speed',                 'type' => 'number',                 'section' => 'configuraes_section',                 'desc' => 'Velocidade em segundos',             ),             array(                 'label' => 'Tempo para troca de slide',                 'id' => 'sc_slider_timeout',                 'type' => 'number',                 'section' => 'configuraes_section',                 'desc' => 'Tempo em segundos',             ),             array(                 'label' => 'Pausar ao parar o mouse',                 'id' => 'sc_slide_mouse',                 'type' => 'radio',                 'section' => 'configuraes_section',                 'options' => array(                     'Sim' => 'Sim',                     'Não' => 'Não',                 ),             ),         );         foreach( $  fields as $  field ){             add_settings_field( $  field['id'], $  field['label'], array( $  this, 'wph_field_callback' ), 'configuraes', $  field['section'], $  field );             register_setting( 'configuraes', $  field['id'] );         }     }      public function wph_field_callback( $  field ) {         $  value = get_option( $  field['id'] );         $  placeholder = '';         if ( isset($  field['placeholder']) ) {             $  placeholder = $  field['placeholder'];         }         switch ( $  field['type'] ) {                 case 'radio':                     if( ! empty ( $  field['options'] ) && is_array( $  field['options'] ) ) {                         $  options_markup = '';                         $  iterator = 0;                         foreach( $  field['options'] as $  key => $  label ) {                             $  iterator++;                             if (!is_array($  value)) {                                 $  value = str_split($  value);                             };                             $  options_markup.= sprintf('<label for="%1$  s_%6$  s"><input id="%1$  s_%6$  s" name="%1$  s[]" type="%2$  s" value="%3$  s" %4$  s /> %5$  s</label><br/>',                             $  field['id'],                             $  field['type'],                             $  key,                             checked($  value[array_search($  key, $  value, true)], $  key, false),                             $  label,                             $  iterator                             );                             }                             printf( '<fieldset>%s</fieldset>',                             $  options_markup                             );                     }                     break;                 case 'select':                 case 'multiselect':                     if( ! empty ( $  field['options'] ) && is_array( $  field['options'] ) ) {                         $  attr = '';                         $  options = '';                         foreach( $  field['options'] as $  key => $  label ) {                             $  selectedvalue = false;                             if (is_array($  value))  {                                 $  selectedvalue = array_search($  key, $  value, true);                             };                             $  options.= sprintf('<option value="%s" %s>%s</option>',                                 $  key,                                 selected($  value[$  selectedvalue], $  key, false),                                 $  label                             );                         }                         if( $  field['type'] === 'multiselect' ){                             $  attr = ' multiple="multiple" ';                         }                         printf( '<select name="%1$  s[]" id="%1$  s" %2$  s>%3$  s</select>',                             $  field['id'],                             $  attr,                             $  options                         );                     }                     break;             default:                 printf( '<input name="%1$  s" id="%1$  s" type="%2$  s" placeholder="%3$  s" value="%4$  s" />',                     $  field['id'],                     $  field['type'],                     $  placeholder,                     $  value                 );         }         if( isset($  field['desc']) ) {             if( $  desc = $  field['desc'] ) {                 printf( '<p class="description">%s </p>', $  desc );             }         }     } } new configuraes_Settings_Page(); 

But this submenu doesn’t appears. How can I do this?

Highlight “shop” in menu when on product page, without showing a sub-menu?

I’ve tried doing some research on this but can’t get my head around it…

I have one main menu where I want to highlight a page (named “Shop”), but don’t want a dropdown menu with sub-pages (product categories and products). I want the customer to click on “Shop” and then go from there.

I understand that I can get “Shop” highlighted by creating a page hierchy and then disable the dropdown sub-menu from showing up. But if I do this, then my second menu won’t have a dropdown sub-menu which is necessary.

Any ideas?