How can I remove the hyperlink to posts on the edit.php screen when listing all posts?
I am already removing the on hover links using the code below, but I want the actual post titles not to be hyperlinked at all.
add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 );
function remove_row_actions( $actions )
{
if( get_post_type() === 'wprss_feed_item' )
unset( $actions['edit'] );
unset( $actions['view'] );
unset( $actions['trash'] );
unset( $actions['inline hide-if-no-js'] );
return $actions;
}
I also tried adding a column instead of the title column, and then echoing get_the_title() within that column. However in that case, although I would get rid of the hyperlink, I would lose the WP functionality that adds the quick links for trashing, editing etc. beneath the post title.
I also tried the following with no success:
add_filter( 'edit_post_link', 'remove_hyperlink_from_food_titles');
function remove_hyperlink_from_food_titles() {
if ( 'edit-food_item' !== get_current_screen()->id )
return;
return get_the_title();
}
2 Answers
You can remove the a tag with javascript, short and easy.
Use the follow plugin; include a small script in the footer of the edit.php
, only this page in backend of WP and remove all a-tag inside the table; see the selector on the source below.
<?php
/**
* Plugin Name: Remove a
* Version: 0.0.1
* Plugin URI: http://wordpress.stackexchange.com/questions/65613/
* Description:
* Author: Frank Bültge
* Author URI: http://bueltge.de
*/
if ( ! function_exists( 'wpse65613_remove_a' ) ) {
add_action( 'admin_footer-edit.php', 'wpse65613_remove_a' );
function wpse65613_remove_a() {
?>
<script type="text/javascript">
jQuery('table.wp-list-table a.row-title').contents().unwrap();
</script>
<?php
}
}
The result: