WordPress.org

Ready to get started?Download WordPress

Forums

Media Category Library
Get Media Matching ALL Categories (2 posts)

  1. stuartwells
    Member
    Posted 1 year ago #

    I was thinking of flagging document as several categories (like 'Minutes', 'Youth Club', 'Village Hall', 'School' etc such that if I wanted to show all the Youth Club Minutes (i.e.AND) I would specify both categories, but is is bring back any document with any (OR) of the mentioned categories.

    Maybe a notation (+ instead of ,) or a simple option any|all?

    http://wordpress.org/extend/plugins/media-category-library/

  2. tsoheili
    Member
    Posted 1 year ago #

    This is what I did for a template page I created for a similar situation.

    <div id="content" class="hfeed">
            <?php the_content(); ?>
    		<? echo "<h1 class=\"entry-title\">Category Filtering</h1>";?>
            <div id="category-options">
                <form method="post" action="">
                    <p><input id="papers" type="checkbox" name="papers" value="Featured Paper, Feature Papers, Second Edition, Second Editions, Student Paper, Student Papers" <? if(isset($_POST['papers'])) { echo "checked"; }?>><label for="papers"> Papers</label></p>
                    <p><input id="articles" type="checkbox" name="articles" value="Commentary, Commentaries, Articles, Advisory Article, Advisory Articles, Series Article, Series Articles" <? if(isset($_POST['articles'])) echo "checked"; ?>><label for="articles"> Articles</label></p>
                    <p><input id="book-reviews" type="checkbox" name="book-reviews" value="Book Review, Book Reviews" <? if(isset($_POST['book-reviews'])) echo "checked"; ?> >
                    <input type="hidden" name="cats" value="1"><label for="book-reviews">Book Reviews</label></p>
                    <input type="submit" name="submit" value="Submit">
                </form>
            </div>
            <div id="category-results">
                <?php
                if(isset($_POST['cats'])) {
                    $cats = "";
                    $comma = ", ";
    
                    //check if the papers checkbox was clicked and update the categories to filter by
                    if(isset($_POST['papers'])) {
                        $cats = mysql_real_escape_string(htmlentities($_POST['papers']));
                    }
    
                    //check if the articles checkbox was clicked and update the categories to filter by, accordingly
                    if(isset($_POST['articles'])) {
                        if(strlen($cats) > 1) { $cats = $cats.$comma; }
                        $cats .= mysql_real_escape_string(htmlentities($_POST['articles']));
                    }
                    //check if the book-reports checkbox was clicked and update the categories to filter by, accordingly
                    if(isset($_POST['book-reviews'])) {
                        if(strlen($cats) > 1) { $cats = $cats.$comma; }
                        $cats .= mysql_real_escape_string(htmlentities($_POST['book-reviews']));
                    }
    
                    $str = '[mediacat cats="'.$cats.'" orderby="date" order="DESC"]';
                    echo do_shortcode($str);
                ?>
            </div>
        <?php } ?>
        </div>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.