Is there a way to keep a custom menu expanded when editing a custom post type?

I figured this out by putting the main menu slug into the show_in_menu key of the custom post type array like so: $args = array ( ‘labels’ => $labels, ‘hierarchical’ => FALSE, ‘description’ => $title . ‘s’, ‘supports’ => array( ‘title’ ), ‘show_ui’ => TRUE, ‘show_in_menu’ => ‘squirrels_inventory’, ‘show_in_nav_menus’ => TRUE, ‘publicly_queryable’ => TRUE, ‘exclude_from_search’ … Read more

Listing posts with wp-cli

the first request doesn’t show any custom post type (polylang_mo is a custom post type) polylang_mo is a private custom post type so unless I explicitly request this post type, it won’t be included. the second request shows only 1 page (instead of 3) Polylang was actually filtering the results. Adding –skip-plugins=polylang makes the 3 … Read more

Create user role restricted to specific CPT

You need to register the CPT with your custom capability, then assign that specific cap to the user. When passing the arguments to register_post_type, set capability_type to your new capability, so the check turns into ‘edit_cpts’ instead of ‘edit_post’. By setting ‘capability_type’ => [ ‘cpt’, ‘cpts’ ], ‘cpt’ will map to ‘post’ for standard capability … Read more

Getting a div content of a post in wordpress?

Using DOMDocument and DOMXPath you could try this. <?php while (have_posts()) : the_post(); ob_start(); // run the_content() through the Output Buffer the_content(); $html = ob_get_clean(); // Store the formatted HTML $content = new DomDocument(); // Create a new DOMDocument Object to work with our HTML $content->loadHTML( $html ); // Load the $html into the new … Read more

Permalink for CPT with taxonomy

(Updated/new answer) So here I’m going straight to the code you need: (but do read the updated version of the original answer) Register the CPT’s and Set the proper rewrite slug This is for the “English Speaking” CPT, which is assigned to the custom taxonomy “Speaking Task”: register_post_type( ‘english-speaking’, array( ‘label’ => ‘English Speaking’, ‘public’ … Read more