Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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();
}
share|improve this question

2 Answers 2

up vote 3 down vote accepted

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: enter image description here

share|improve this answer

All you're searching for is right inside ~/wp-admin/includes/screen.php.

We even got a tag for it: .

If you can't around it, you can still use a silly solution. Replace the link with # and change the CSS styles.

<?php
! defined( 'ABSPATH' ) AND exit;
/** Plugin Name: (#65629) »kaiser« Change WP List Table row title */

function wpse65629_row_title_styles()
{
    ?>
    <style type="text/css">
        #the-list .row-title {
            cursor: default;
            font-weight: normal;
            color: #555;
        }
    </style>
    <?php
}
add_action( 'admin_head-edit.php', 'wpse65629_row_title_styles' );

function wpse65629_change_row_title( $url, $post_id, $context )
{
    if ( 'edit-post' !== get_current_screen()->id )
        return;

    return '#';
}
add_filter( 'get_edit_post_link', 'wpse65629_change_row_title', 10, 3 );
share|improve this answer
    
Still can't find a way to remove the hyperlink, I only arrived till removing a column completely. –  drtanz Sep 19 '12 at 15:21
    
I don't think that is what @drtanz is asking. Granted, I only just looked through screen.php (thinking it would help with an issue I am having), but it seems totally unrelated to changing how the title column is displayed. As far as I know (which may not be far) there is no way to alter the switch cases for the single_row() method of WP_List_Table. You can add columns but not change existing ones. –  helgatheviking Sep 19 '12 at 15:52
    
@helgatheviking For you a quick fix. See update. –  kaiser Sep 19 '12 at 16:56
    
@kaiser thanks I see how this works now. I tried using the edit_post_link filter, as I am trying to eliminate the link completely (no a tags), and I posted the code in my update to the original question. Didn't work however, is it not possible to use that filter here? –  drtanz Sep 19 '12 at 17:59
    
@drtanz A look at the source will answer your question. –  kaiser Sep 19 '12 at 18:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.