- Overview
- Transcript
2.3 Removing Unnecessary Table Columns
Tables are used throughout the admin UI to display various bits of information about specific elements: posts, pages, comments and so on. The thing is, these tables sometimes show unnecessary columns, which can bloat the interface.
So, let’s see how we can remove them.
Related Links
1.Introduction3 lessons, 06:23
1.1Welcome00:49
1.2About the WordPress Back-End02:53
1.3Reasons You Might Consider Customization02:41
2.Customization: Smaller Tasks6 lessons, 38:49
2.1Cleaning Up and Organizing the Left Menu14:42
2.2Reinventing the Dashboard Screen04:16
2.3Removing Unnecessary Table Columns03:00
2.4Adding Help08:20
2.5Setting User Permissions02:33
2.6Other Small Customizations05:58
3.Customization: Bigger Tasks5 lessons, 24:53
3.1Adding New Colour Schemes04:20
3.2Customizing the Login Screen08:47
3.3Changing the Default Admin Bar05:09
3.4Customizing the Posts and Pages Editing Screens02:37
3.5Changing the Admin Theme Entirely04:00
4.Conclusion1 lesson, 00:40
4.1Final Words and Assignment00:40
2.3 Removing Unnecessary Table Columns
Tables are used throughout the admin UI to show various bits of information about different elements, like post, pages, comments, and so on. But, the thing is, sometimes they show some unnecessary columns. For example, if you're not using the comments system, it doesn't make sense to show this column when viewing the post list. So let's see how we can remove some of these columns that we don't actually need. Let's have a look at the articles here. And let's say that we wanna remove the tags and the comments. Well, one way of doing it is from screen options. So, you can see I already unchecked categories here, so I can uncheck tags and comments. But, what if, we wanna remove them completely? Well, it's actually very simple. Let's write a function that's called customize posts listing coles, or columns. And we're gonna pass in columns. And this function, will be tied in, via hook, to manage posts columns. So, first things first, let's actually do a print R of columns, to see what's going on there. And you can see that for each column, we have the title here. So author, title, categories, tags, date and so on. We can do something like this, unset, columns, tags, for example. And then we're gonna return, the new columns. Let's refresh, and now the tags are gone and they're also gone from the screen options here, right? So let's actually remove comments and categories as well, we'll do the same, and now these are gone and they're gone from the screen options as well. And that's it. Very very simple. Now, you can do the same for pages because on pages, you can see that we still have comments here. So if you wanna remove this from pages, you would actually have to write another function. So let's copy this function here. And this is gonna be four pages, so pages list in cols but the idea is the same. You would unset comments, return it, and then we need to add another hook here manage_pages_columns and then customize pages_listing_cols. So now, the comments are gone. And, that's how you remove the table columns you don't need. Now, whenever you're building a WordPress theme, it's always a nice thing to include documentation, so that whoever will be using it, doesn't run into any problems. Fortunately, you can add documentation directly into the admin UI. So, coming up next we'll find out how.