WordPress.org

Ready to get started?Download WordPress

Forums

Media Category Library
[resolved] Show a list of all documents grouped by category (6 posts)

  1. TSSpkDev
    Member
    Posted 1 year 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/

  2. timmcdaniels
    Member
    Plugin Author

    Posted 1 year 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; ?>
  3. TSSpkDev
    Member
    Posted 1 year 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; ?>
  4. timmcdaniels
    Member
    Plugin Author

    Posted 1 year ago #

    Looks great!

  5. soniczoo
    Member
    Posted 1 year 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!

  6. martinbeasnunez
    Member
    Posted 1 year ago #

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

    with a url for each category?

    be possible?

    regards!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.