TSSpkDev
Member
Posted 8 months ago #
Hi,
I have a feature request.
I'd like to loop through all of documents and group them by category.
I'd prefer to do this w/ a query because this page will never change - it will just be a repository for every document of a certain type.
So - all PDFs that have a category assigned (some are random and not worthy of a category or of display on this page) would show up down the page with a category heading above the group.
Thanks!!
http://wordpress.org/extend/plugins/media-category-library/
timmcdaniels
Member
Plugin Author
Posted 8 months ago #
You could modify the code below to do what you need, I believe:
<?php if ( method_exists( $media_cat_lib, 'get_mediacategory_shortcode' ) && method_exists( $media_cat_lib, 'get_media_categories' ) ): ?>
<?php foreach ( array_keys ( $media_cat_lib->get_media_categories( true ) ) as $cat ): ?>
<h4><?php echo $cat; ?></h4>
<?php echo $media_cat_lib->get_mediacategory_shortcode( array( 'cats' => $cat, 'orderby' => "date", 'order' => "DESC" ) ); ?>
<?php endforeach; ?>
<?php endif; ?>
TSSpkDev
Member
Posted 8 months ago #
Perfect!
Here is what I'm using:
<?php if ( method_exists( $media_cat_lib, 'get_mediacategory_shortcode' ) && method_exists( $media_cat_lib, 'get_media_categories' ) ): ?>
<?php foreach ( array_keys ( $media_cat_lib->get_media_categories( true ) ) as $cat ): ?>
<h4><?php echo $cat; ?></h4>
<?php $posts= $media_cat_lib->get_mediacategory_shortcode( array( 'returnposts' => 1,'cats' => $cat, 'orderby' => "date", 'order' => "DESC" ) ); ?>
<?php foreach ( $posts as $rpost ): ?>
<div><a target="_blank" href="<?php echo wp_get_attachment_url( $rpost->ID ); ?>"><?php echo get_the_title( $rpost->ID ); ?></a>(<?php echo get_the_date( $date_format, $post->ID ); ?>)</div>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endif; ?>
timmcdaniels
Member
Plugin Author
Posted 8 months ago #
soniczoo
Member
Posted 6 months ago #
Hi
thanks for a great plugin. I would like to do the same as TSSpkDev. I can not work out which file to modify. I thought it would be /views/shortcode.php but wherever I tried your code it di not work. Which file do I modify please?
Thanks again!
martinbeasnunez
Member
Posted 5 months ago #
would not be better to have a list of files automatically?
with a url for each category?
be possible?
regards!