admin管理员组文章数量:1287656
Currently i m using this shorocdes
add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 );
function remove_row_actions( $actions )
{
if( get_post_type() === 'post' )
unset( $actions['edit'] );
return $actions;
}
for removing edit link from published post but this code is applied on all post states and i want to apply this filter only for published and pending post. can any one help me to apply this filter only for published and pending post instead of All posts
Currently i m using this shorocdes
add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 );
function remove_row_actions( $actions )
{
if( get_post_type() === 'post' )
unset( $actions['edit'] );
return $actions;
}
for removing edit link from published post but this code is applied on all post states and i want to apply this filter only for published and pending post. can any one help me to apply this filter only for published and pending post instead of All posts
Share Improve this question edited Sep 15, 2021 at 17:32 techno tech asked Sep 15, 2021 at 17:00 techno techtechno tech 286 bronze badges1 Answer
Reset to default 0Try this, where I changed the function to accept the second parameter which is the current post in the list table:
add_filter( 'post_row_actions', 'remove_row_actions', 10, 2 );
function remove_row_actions( $actions, $post )
{
if ( $post && 'post' === $post->post_type &&
in_array( $post->post_status, array( 'publish', 'pending' ) )
) {
unset( $actions['edit'] );
}
return $actions;
}
本文标签: functionsremove edit link only for published post and pending post
版权声明:本文标题:functions - remove edit link only for published post and pending post 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741318002a2372034.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论