Support » Plugin: Media Category Library » [Plugin: Media Category Library] Show a list of all documents grouped by category

  • Resolved TSSpkDev

    (@tsspkdev)


    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/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author timmcdaniels

    (@timmcdaniels)

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

    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; ?>
    Plugin Author timmcdaniels

    (@timmcdaniels)

    Looks great!

    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!

    would not be better to have a list of files automatically?

    with a url for each category?

    be possible?

    regards!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Media Category Library] Show a list of all documents grouped by category’ is closed to new replies.