Support » Fixing WordPress » Searching by post formats

  • Having some difficulty coming up with a method for searching by “post formats“.

    I’ve successfully implemented some code that uses the wp_dropdown_categories function to allow searches to be filtered by category and taxonomy via drop down selectors.

    But I’m a bit stuck on how to add filtering for post formats.

    Does anyone have a method for doing this that doesn’t involve creating a redundant, tag, category or taxonomy to mirror post_format types for use in the wp_dropdown_categories ‘taxonomy’ argument?

    Thanks in advance.

    Here is where I’m at:

    <fieldset>
    <label>Keywords</label>
    <input type="text" class="search form-text" name="s" id="s" value="<?php echo trim( get_search_query() ); ?>" placeholder="Type keywords here" />
    </fieldset>
    
    <fieldset>
    <label>Category</label>
    <div class="styled-select">
    <div class="icon"></div>
    <?php wp_dropdown_categories('&show_option_none=All&&hide_empty=0'); ?>
    </div>
    </fieldset>
    
    <fieldset>
    <label>My Taxonomy</label>
    <div class="styled-select">
    <div class="icon"></div>
    <?php wp_dropdown_categories(array('taxonomy'=> 'MyTaxonomy','hide_empty' => 0, 'show_option_none' => 'All')); ?>
    </div>
    </fieldset>
    
    <fieldset class="submit">
    <input type="submit" class="submit button btn-blue" name="submit" id="searchsubmit" value="Search"/>
    </fieldset>
    </form>

    This is what I wish existed:

    <fieldset>
    <label>Post Format</label>
    <div class="styled-select">
    <div class="icon"></div>
    <?php wp_dropdown_post_format('&show_option_none=All&&hide_empty=0'); ?>
    </div>
    </fieldset>
  • The topic ‘Searching by post formats’ is closed to new replies.