Viewing 1 replies (of 1 total)
  • 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>
Viewing 1 replies (of 1 total)
  • The topic ‘Get Media Matching ALL Categories’ is closed to new replies.