I have just created a quick hack to do this.
From this hack a complete functionality could easily be implemented in an actual release.
This quick hack adds a term tag to each document-icon div like:
(yes it could properly be renamed to either terms or categories for clarity)
The tag will then be filled with a comma separated list of terms/categories.
<div class="document-icon" term="OneCategory, AnotherCategory"></div>
You can then easily with JS sort your documents, or extract the data from the tag to a badge or whatever.
Either just replace your /inc/class-document.php file with this one:
https://pastebin.com/tWMK7eeL
Or do the few modifications below to get an overview of what is going on.
Plugin edit how-to:
1 ) in the plugins folder open the file /inc/class-document.php
2) In the constructor ( the __construct function ) add this:
$this->terms = wp_get_post_terms( $attachment->ID,'media_category');
$this->terms = wp_list_pluck( $this->terms, 'name' );
$this->terms = implode ("','", $this->terms);
Remember to change media_category to whatever your taxonomy is named if it is different from this one from Enhanced Media Library.
3) Then in the same file edit the __tostring function to add
$this->terms
To the $repl array
'%terms%',
To the $find array
And last add
terms="%terms%"
To the div tag in the $doc_icon variable
That’s it. You now get all the appropriate categories dumped in a tag for each document.
___
EDIT (dirty front end hack to display the categories):
Dump this js to your front-end to get some tags in your document-icon div extracted from the term tag:
(requires jquery – bootstrap used for styling here)
$('.document-icon').each(function (i) {
var t = $(this);
var terms = t.attr('terms');
if (terms !== undefined) {
var termsArr = terms.split(',');
console.log(termsArr);
}
termsArr.forEach(function(v){
t.append('<span class="badge badge-primary">'+ v + '</span>');
});
});
-
This reply was modified 6 years, 4 months ago by
jelixir.
-
This reply was modified 6 years, 4 months ago by
jelixir.
-
This reply was modified 6 years, 4 months ago by
jelixir.
-
This reply was modified 6 years, 4 months ago by
jelixir.
-
This reply was modified 6 years, 4 months ago by
jelixir.
-
This reply was modified 6 years, 4 months ago by
jelixir.
-
This reply was modified 6 years, 4 months ago by
jelixir.