Skip to main content
edited title
Source Link
mohsin
  • 177
  • 2
  • 9

post row actions filter does not bring Not able to get all the actions (View, Edit, Quick Edit, Trash), and not able to delete post in custom post type

Post row actionspost_row_actions, This filter does not bring all rowthe actions when I try to print_r

public function remove_quick_edit($actions) {
 
        global $post;

        echo "<pre>";
           print_r($actions);
        echo "</pre>"; 
                    
        $link_get = get_delete_post_link($post->ID);

        if ( $post->post_type == 'cs_flags' ) {
            
            unset($actions['inline hide-if-no-js']);
            unset($actions['trash']);                           
            
            $actions['delete'] = '<span class="trash"><a class="submitdelete deletion" href="' . get_delete_post_link($post->ID, '', true) . '">' . esc_html__('Delete', 'jobhunt') . '</a></span>';                
        }
        
        return $actions;
    }

The result it brings is only views it should bring edit and trash also but only view is there.

I was debugging why get_delete_post_link not working, so I found this issue maybe they are related to each other.

http://prntscr.com/gxz0fu

Custom post type code

$args = array(
            'label' => __( 'Flags' ),
            'description' => esc_html__( 'This is Description' ),
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => 'edit.php?post_type=jobs',
            'menu_position' => true,
            'supports' => array( 'title' ),
            'exclude_from_search' => true,
            'capabilities' => array(
        'create_posts' => false,
        'delete_posts' => true
    )
        );
        register_post_type( 'cs_flags', $args );
    }

post row actions filter does not bring all the actions

Post row actions filter does not bring all row actions when I try to print_r

public function remove_quick_edit($actions) {
 
        global $post;

        echo "<pre>";
           print_r($actions);
        echo "</pre>"; 
                    
        $link_get = get_delete_post_link($post->ID);

        if ( $post->post_type == 'cs_flags' ) {
            
            unset($actions['inline hide-if-no-js']);
            unset($actions['trash']);                           
            
            $actions['delete'] = '<span class="trash"><a class="submitdelete deletion" href="' . get_delete_post_link($post->ID, '', true) . '">' . esc_html__('Delete', 'jobhunt') . '</a></span>';                
        }
        
        return $actions;
    }

The result it brings is only views it should bring edit and trash also but only view is there.

I was debugging why get_delete_post_link not working, so I found this issue maybe they are related to each other.

http://prntscr.com/gxz0fu

Custom post type code

$args = array(
            'label' => __( 'Flags' ),
            'description' => esc_html__( 'This is Description' ),
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => 'edit.php?post_type=jobs',
            'menu_position' => true,
            'supports' => array( 'title' ),
            'exclude_from_search' => true,
            'capabilities' => array(
        'create_posts' => false,
        'delete_posts' => true
    )
        );
        register_post_type( 'cs_flags', $args );
    }

Not able to get all the actions (View, Edit, Quick Edit, Trash), and not able to delete post in custom post type

post_row_actions, This filter does not bring all the actions when I try to print_r

public function remove_quick_edit($actions) {
 
        global $post;

        echo "<pre>";
           print_r($actions);
        echo "</pre>"; 
                    
        $link_get = get_delete_post_link($post->ID);

        if ( $post->post_type == 'cs_flags' ) {
            
            unset($actions['inline hide-if-no-js']);
            unset($actions['trash']);                           
            
            $actions['delete'] = '<span class="trash"><a class="submitdelete deletion" href="' . get_delete_post_link($post->ID, '', true) . '">' . esc_html__('Delete', 'jobhunt') . '</a></span>';                
        }
        
        return $actions;
    }

The result it brings is only views it should bring edit and trash also but only view is there.

I was debugging why get_delete_post_link not working, so I found this issue maybe they are related to each other.

http://prntscr.com/gxz0fu

Custom post type code

$args = array(
            'label' => __( 'Flags' ),
            'description' => esc_html__( 'This is Description' ),
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => 'edit.php?post_type=jobs',
            'menu_position' => true,
            'supports' => array( 'title' ),
            'exclude_from_search' => true,
            'capabilities' => array(
        'create_posts' => false,
        'delete_posts' => true
    )
        );
        register_post_type( 'cs_flags', $args );
    }
Source Link
mohsin
  • 177
  • 2
  • 9

post row actions filter does not bring all the actions

Post row actions filter does not bring all row actions when I try to print_r

public function remove_quick_edit($actions) {
 
        global $post;

        echo "<pre>";
           print_r($actions);
        echo "</pre>"; 
                    
        $link_get = get_delete_post_link($post->ID);

        if ( $post->post_type == 'cs_flags' ) {
            
            unset($actions['inline hide-if-no-js']);
            unset($actions['trash']);                           
            
            $actions['delete'] = '<span class="trash"><a class="submitdelete deletion" href="' . get_delete_post_link($post->ID, '', true) . '">' . esc_html__('Delete', 'jobhunt') . '</a></span>';                
        }
        
        return $actions;
    }

The result it brings is only views it should bring edit and trash also but only view is there.

I was debugging why get_delete_post_link not working, so I found this issue maybe they are related to each other.

http://prntscr.com/gxz0fu

Custom post type code

$args = array(
            'label' => __( 'Flags' ),
            'description' => esc_html__( 'This is Description' ),
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => 'edit.php?post_type=jobs',
            'menu_position' => true,
            'supports' => array( 'title' ),
            'exclude_from_search' => true,
            'capabilities' => array(
        'create_posts' => false,
        'delete_posts' => true
    )
        );
        register_post_type( 'cs_flags', $args );
    }