Support » Developing with WordPress » Custom post type not showing bulk actions in list page

  • Resolved Venutius

    (@venutius)


    I’ve created a custom post type, overall it’s working well however the bulk actions are missing from the posts lists pages. I’ve reviewed all the settings options and there does not seem to be one to add this so I’m thinking there must be some other problem. Would anyone have any ideas why this would be missing?

    Thanks in advance.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator t-p

    (@t-p)

    Thread Starter Venutius

    (@venutius)

    Thanks, unfortunately I’ve got all those options explicitly declared but still no Bulk Actions.

    Moderator t-p

    (@t-p)

    See if this info points you in the right direction:
    https://www.skyverge.com/blog/add-custom-bulk-action/

    Thread Starter Venutius

    (@venutius)

    Seems you can only add bulk actions to an already showing bulk action filter, and since I’ve not got that filter showing when I update that plugin for my own post type it fails to add anything.

    Thanks for helping out though, research is never wasted, if I do get this fixed I’d like to add an export option for my custom post type.

    Moderator t-p

    (@t-p)

    you are welcome 🙂

    Moderator bcworkz

    (@bcworkz)

    That skyverge article is outdated. No need to use jQuery any more. Since WP v4.7, there is a built-in mechanism to add bulk actions. When the WP_Posts_Lists_Table class is used to list posts, AFAIK the proper filter is always in place, even if there are initially no bulk actions. Please review this “Make” post for an example of adding bulk actions.

    If you still have trouble, please post the related code you are using. You mention updating a plugin for your post type. What plugin is this? It’s possible there is some conflict with your theme or other plugins that’s preventing bulk actions from appearing. If you can isolate the custom post type and bulk action code into a stand alone plugin, you would be able to use bulk actions by deactivating all other plugins and switching to the twentyseventeen theme. Selectively restoring your site’s modules will reveal the conflict. The health-check plugin’s troubleshooting tab makes this fairly painless.

    Thread Starter Venutius

    (@venutius)

    Sorry it’s taken me so long to reply, I had other issues that kept me away from this.

    I’ve tried several methods of adding bulk actions but nothing I do makes the bulk actions fields show.

    Here is the code I’m using to create my two custom post types. Neither of them have bulk actions available. standard posts and pages have the bulk actions.

    function busl_register_post_type() {
    
    	$singular = __( 'Site' );
    	$plural = __( 'Sites' );
            //Used for the rewrite slug below.
        $plural_slug = str_replace( ' ', '_', $plural );
    
            //Setup all the labels to accurately reflect this post type.
    	$labels = array(
    		'name' 					=> $plural,
    		'singular_name' 		=> $singular,
    		'add_new' 				=> 'Add New',
    		'add_new_item' 			=> 'Add New ' . $singular,
    		'edit'		        	=> 'Edit',
    		'edit_item'	        	=> 'Edit ' . $singular,
    		'new_item'	        	=> 'New ' . $singular,
    		'view' 					=> 'View ' . $singular,
    		'view_item' 			=> 'View ' . $singular,
    		'search_term'   		=> 'Search ' . $plural,
    		'parent' 				=> 'Parent ' . $singular,
    		'not_found' 			=> 'No ' . $plural .' found',
    		'not_found_in_trash' 	=> 'No ' . $plural .' in Trash'
    	);
    
            //Define all the arguments for this post type.
    	$args = array(
    		'labels' 			  => $labels,
    		'public'              => true,
            'publicly_queryable'  => true,
            'exclude_from_search' => false,
            'show_in_nav_menus'   => true,
            'show_ui'             => true,
            'show_in_menu'        => true,
    		'show_in_nav_menus'	  => true,
            'show_in_admin_bar'   => true,
            'menu_position'       => 3,
            'menu_icon'           => 'dashicons-admin-site',
            'can_export'          => true,
            'delete_with_user'    => false,
            'hierarchical'        => true,
            'has_archive'         => true,
            'query_var'           => true,
            'capability_type'     => 'post',
            'map_meta_cap'        => true,
            // 'capabilities'     => array(),
    		'rewrite'		      => array( 
    			'slug' 	          => strtolower( $plural_slug ),
    			'with_front'      => true,
    		),
    		'pages'     	      => true,
    		'feeds'         	  => false,
            'supports'            => array( 
            	'title',
    			'thumbnail',
    			'excerpt'
            ),
    		'taxonomies' => array(
    			'category',
    			'post_tag'
    		)
    		);
    
            //Create the post type using the above two variables.
    	register_post_type( 'buslsite', $args);
    	
    	$singular = __( 'Find' );
    	$plural = __( 'Finds' );
    	
        $plural_slug = str_replace( ' ', '_', $plural );	
    	
        $labels = array(
            'name' 					=> $plural,
    		'singular_name' 		=> $singular,
    		'add_new' 				=> 'Add New',
    		'add_new_item' 			=> 'Add New ' . $singular,
    		'edit'		        	=> 'Edit',
    		'edit_item'	        	=> 'Edit ' . $singular,
    		'new_item'	        	=> 'New ' . $singular,
    		'view' 					=> 'View ' . $singular,
    		'view_item' 			=> 'View ' . $singular,
    		'search_term'   		=> 'Search ' . $plural,
    		'parent' 				=> 'Parent ' . $singular,
    		'not_found' 			=> 'No ' . $plural .' found',
    		'not_found_in_trash' 	=> 'No ' . $plural .' in Trash'
        );
    
        $args = array(
            'labels' 				=> $labels,
            'description' 			=> '',
            'public' 				=> true,
            'show_ui' 				=> true,
            'has_archive' 			=> true,
            'show_in_menu' 			=> true,
    		'menu_position' 		=> 7,
            'exclude_from_search' 	=> false,
            'capability_type' 		=> 'post',
            'map_meta_cap' 			=> true,
            'hierarchical' 			=> false,
            'rewrite' 				=> array(
    			'slug' 			=> strtolower( $plural_slug ),
    			'with_front' 	=> true 
    		),
            'query_var' 			=> true,
            'supports' 				=> array( 
    			'title',
    			'thumbnail',
    			'excerpt'
    		),
    		'taxonomies' 			=> array(
    			'category',
    			'post_tag'
    			)
        );
    
        register_post_type( "buslfind", $args );
    
    	
    }
    add_action( 'init', 'busl_register_post_type', 1 );
    Thread Starter Venutius

    (@venutius)

    Problem solved! problem was down to a typo in a css file causing the bulk actions to become hidden.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom post type not showing bulk actions in list page’ is closed to new replies.