post_row_actions not working for hierarchical post type
I'm working on a plugin where I have a Custom Post Type (CPT) registered and I need to add custom row actions to that particular post type. But could not make the following code hooked to post_row_actions
work:
function ttest_copy_button( $actions, $post )
{
// var_dump($actions);
if( 'ttest' === $post-post_type ) {
// pass nonce to check and verify false request
$nonce = wp_create_nonce( 'copy_content' );
// add our button
$actions['copy_content'] = 'a data-nonce="'. $nonce .'" href="javascript:" role="button"'. esc_html__( 'Copy Content', 'ttest' ) .'/a';
}
return $actions;
}
add_filter( 'post_row_actions', 'ttest_copy_button', 10, 2 );
My CPT code is:
function ttest_register_cpt() {
register_post_type( 'ttest', array(
'labels' = array(
'menu_name' = __('TTest', 'ttest')
),
'hierarchical' = true,
'description' = __( 'Get the test information', 'ttest' ),
'supports' = array( 'title', 'editor', 'excerpt', 'page-attributes' ),
'taxonomies' = array(),
'menu_icon' = 'dashicons-book-alt',
'public' = true,
'show_ui' = true,
'show_in_menu' = true,
'menu_position' = 6,
'show_in_nav_menus' = false,
'publicly_queryable' = true,
'exclude_from_search' = false,
'has_archive' = true,
'query_var' = true,
'can_export' = true,
'rewrite' = array( 'slug' = 'ttest' ),
'capability_type' = 'post'
) );
}
add_action( 'init', 'ttest_register_cpt', 5 );
When the var_dump($actions);
line is active I see the code dump in all the other default post types, even on the WooCommerce product
post type, but not in my custom post type.
What am I doing wrong?
Topic row-actions hierarchical custom-post-types Wordpress
Category Web