WordPress.org

Ready to get started?Download WordPress

Forums

Add slug to screen options on post page (9 posts)

  1. eagerwatcher
    Member
    Posted 2 years ago #

    Hi,

    I'd like to be able to see slugs on the posts page.

    http://i41.tinypic.com/vonabo.jpg

    Spent time looking of the web but so far found nothing.

    Any help would be much appreciated.

    Jane

  2. eagerwatcher
    Member
    Posted 2 years ago #

    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

  3. keesiemeijer
    moderator
    Posted 2 years ago #

    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;
    	}
    }
  4. eagerwatcher
    Member
    Posted 2 years ago #

    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

  5. keesiemeijer
    moderator
    Posted 2 years ago #

    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?

  6. eagerwatcher
    Member
    Posted 2 years ago #

    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

  7. eagerwatcher
    Member
    Posted 2 years ago #

    I had to upload the file from my pc !

    So something is wrong?!

    Until I uploaded the file the site went dead.

  8. grosner55
    Member
    Posted 2 years ago #

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

  9. grosner55
    Member
    Posted 2 years ago #

    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;
        }

Topic Closed

This topic has been closed to new replies.

About this Topic