WordPress.org

Support

Support » How-To and Troubleshooting » Add slug to screen options on post page

Add slug to screen options on post page

Viewing 8 replies - 1 through 8 (of 8 total)
  • http://codex.wordpress.org/Writing_Posts

    Note: As of WordPress version 3.1, some screen options on the Post Administration Panel are hidden by default if they have not been saved before. Hidden by default: Excerpt, Post Author, Discussion, Custom Fields, Slug, Comments, Send Trackbacks, Revisions.

    So how do I display slugs?

    Thanks

    keesiemeijer
    Moderator

    @keesiemeijer

    Try it with this in your theme’s functions.php:

    add_filter('manage_posts_columns', 'my_column');
    function my_column($defaults){
    	$defaults['my_slug'] = __('slug');	/*Add our column to the list of default columns*/
    	return $defaults;
    }
    
    add_action('manage_posts_custom_column', 'custom_column_data', 10, 2);
    function custom_column_data($column_name, $id) {
    	if( $column_name == 'my_slug' ) {
    		$post_slug = get_post($ID = $id)->post_name;
    		echo $post_slug;
    	}
    }

    http://dpaste.com/707270/

    The above is what I tried and it didn’t work for me but maybe the mistake was mine.

    I was only able to add your code by downloading the file making the addition and then uploading the changed file.

    Couldn’t make the change on line in WP which seems strange.

    I saw a couple of other posts of yours on the same subject, whilst surfing for the answer, so well done for trying to get this sorted out!

    http://misconceptions.us

    keesiemeijer
    Moderator

    @keesiemeijer

    Couldn’t make the change on line in WP which seems strange.

    Do you mean the editor under Appearance > Editor?

    Is it not working after downloading and uploading?

    Do you mean the editor under Appearance > Editor?

    Yes

    Actually I just played a little by removing

    add_filter(‘comments_template’, ‘legacy_comments’);
    function legacy_comments($file) {
    if(!function_exists(‘wp_list_comments’)) : // WP 2.7-only check
    $file = TEMPLATEPATH.’/legacy.comments.php’;
    endif;
    return $file;
    }
    and as when I made your change the screen went white.

    However when I went “page back” the change had been made.

    So I was wrong about the change not getting made.

    It did get made but left me with a white screen instead of showing the change.

    Thanks for hanging in there.

    Jane

    I had to upload the file from my pc !

    So something is wrong?!

    Until I uploaded the file the site went dead.

    grosner55
    Member

    @grosner55

    This code worked for me. Pasted code into in my child theme’s functions.php file.

    grosner55
    Member

    @grosner55

    To Add Slug column to the WordPress Pages list, I modified keesiemeijer code snipet and pasted the following code into my child theme’s function file.

    /*Add Slug to columns on Pages */
    add_filter('manage_pages_columns', 'my_page_column');
    function my_page_column($defaults){
        $defaults['my_slug'] = __('slug');	/*Add our column to the list of default columns*/
        return $defaults;
    }
    
    add_action('manage_pages_custom_column', 'custom_page_column_data', 10, 2);
    function custom_page_column_data($column_name, $id) {
        if( $column_name == 'my_slug' ) {
            $page_slug = get_page($ID = $id)->post_name;
            echo $page_slug;
        }
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Add slug to screen options on post page’ is closed to new replies.