Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home Internet Manage Or Organize WordPress Media Library Structure In Categories

Manage Or Organize WordPress Media Library Structure In Categories

Media Library is the images, videos, files, etc you upload and attach/insert into a Post or a Page. If you have so many media uploaded, it’s hard to manage or remember all of them because by default, WordPress doesn’t support Media Categories like Links or Posts.

On my blog, I’ve uploaded over hundreds of screen shots and source codes in attachments in order for my readers download and understand what I say easier. Without Media Categories, I’m always in trouble whenever I want to find a particular media file which was uploaded long time ago.

WordPress Media Library Preview

WordPress Media Library Preview

I researched a lot and found that there is a WordPress Plugin call Media Library Categories will help to organize your Media Library in Categories. This plugin is very easy to install, allow to create category as many as you want, easier for searching your media by filtering a category name. Every time you upload an attachment, you assign a category for it or you can [re]assign the category later via Edit Media function. And all your media can then be sorted per category, this is the function I like most.

Below are some screenshots I captured on my blog in order for you can preview:

1. Display Media Library In Categories Preview

Media Library  Preview

Media Library Preview

As you can see, there is a new link called Media Categories under Add New link in Media box. On Media Library panel on the right, a new column named Categories show which category a media belongs to. And on the top, you can filter the list easier by selecting a category name in the Show All Media Categories drop down list.

2. Manage Your Media Categories

Manage Your Media Categories Preview

Manage Your Media Categories Preview

Currently, I created 2 categories: Screen Shots and Source Code. Basically, I can create as many as I want by clicking on Add Media Category button on the top. After that, just enter a name for the new category and you’re done.

3. Edit Or Add New Media Preview

Add New Or Edit A Media In Category

Add New Or Edit A Media In Category

Every time you add or edit a media, it allows you to select which category the media belongs to.

How to select all media files in a category

This is a extra part for those who are developers because you have to modify a little bit in your PHP template files. Let say you uploaded some images in a category with ID 4 then you want to display all those images in a particular post or a page template. To do that, just use/modify the PHP code below and replace tt.term_id=4 with your desired category id.

<?php
echo "<ul>";
 
$count = 0;
 
$banners = $wpdb->get_results("
SELECT p.*, a.term_order
FROM
rvsw_posts p inner join
rvsw_term_relationships a on a.object_id = p.ID inner join
rvsw_term_taxonomy ttt on ttt.term_taxonomy_id = a.term_taxonomy_id
inner join rvsw_terms tt on ttt.term_id = tt.term_id
where ttt.taxonomy=’media_category’ && tt.term_id=4
order by a.term_order asc;
 
");
 
foreach ($banners as $banner) {
	$count++;
	echo sprintf("<li class=\"%s\">",($count == 1)?"active":"");
	echo sprintf("<img src=\"%s\" alt=\"%s\" border=\"0\" class=’top_banner’ style=\"display:none;\"/>",$banner->guid,$banner->post_title);
	echo sprintf("<div class=\"ft-title\">%s</div>",$banner->post_title);
	echo sprintf("</li>");
}
echo "</ul>";
?>

<?php echo "<ul>"; $count = 0; $banners = $wpdb->get_results(" SELECT p.*, a.term_order FROM rvsw_posts p inner join rvsw_term_relationships a on a.object_id = p.ID inner join rvsw_term_taxonomy ttt on ttt.term_taxonomy_id = a.term_taxonomy_id inner join rvsw_terms tt on ttt.term_id = tt.term_id where ttt.taxonomy=’media_category’ && tt.term_id=4 order by a.term_order asc; "); foreach ($banners as $banner) { $count++; echo sprintf("<li class=\"%s\">",($count == 1)?"active":""); echo sprintf("<img src=\"%s\" alt=\"%s\" border=\"0\" class=’top_banner’ style=\"display:none;\"/>",$banner->guid,$banner->post_title); echo sprintf("<div class=\"ft-title\">%s</div>",$banner->post_title); echo sprintf("</li>"); } echo "</ul>"; ?>

In the PHP script above, $banner->guid will echo the image URL and $banner->post_title will echo the image title.

It’s cool, isn’t it. I uploaded a copy of the Media Library Categories plugin version 1.0.6 for you to download.

Your feedback or question is always welcome, just leave it in the comments.

May 14, 2011Hoan Huynh
Create And Assign Account To A User In Microsoft Dynamic CRM With C#Auto Convert Text To URL Link And MailTo Email Address With ASP.NET C#
You Might Also Like:
  • How To Get WordPress Tags By Categories
  • WordPress Check If Post Is In Category
  • Generate And Display Related Content On WordPress
  • Top Plugins Should Be Installed On WordPress
  • WordPress Filter/Exclude Posts Category From Displaying In A Specific Page
  • Display Technorati Media Ads In Iframe
  • How To Hide/ Remove / Disable WordPress Top Navigation Bar
  • WordPress Plugin For Header Ad Or Stripe Ad
  • Save Table Structure Changes When Remote Access To SQL Server
  • WordPress Delete Unused Post Tags By SQL Command
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

9 years ago Internetget_results, Media Library, Wordpress1,981
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
21,918 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
19,746 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
15,584 views
JQuery Allow only numeric characters or only alphabet characters in textbox
13,094 views
C# Read Json From URL And Parse/Deserialize Json
9,557 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Research Paper Writing Service
  • Annotated Bibliography Example – How it Can Help You
  • Essay Writing Online Tips – How to Write Essays Online With Essay Proof Editing
  • Get Research Paper Assistance From Professional Help
  • Customized Essay Writing Agency – Why You Want It
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (28)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (62)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development