Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Created January 2, 2012 06:41
Show Gist options
  • Select an option

  • Save alexkingorg/1549613 to your computer and use it in GitHub Desktop.

Select an option

Save alexkingorg/1549613 to your computer and use it in GitHub Desktop.

Revisions

  1. Alex King created this gist Jan 2, 2012.
    29 changes: 29 additions & 0 deletions query_format_standard.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <?php

    function akv3_query_format_standard($query) {
    if (isset($query->query_vars['post_format']) &&
    $query->query_vars['post_format'] == 'post-format-standard') {
    if (($post_formats = get_theme_support('post-formats')) &&
    is_array($post_formats[0]) && count($post_formats[0])) {
    $terms = array();
    foreach ($post_formats[0] as $format) {
    $terms[] = 'post-format-'.$format;
    }
    $query->is_tax = null;
    unset($query->query_vars['post_format']);
    unset($query->query_vars['taxonomy']);
    unset($query->query_vars['term']);
    unset($query->query['post_format']);
    $query->set('tax_query', array(
    'relation' => 'AND',
    array(
    'taxonomy' => 'post_format',
    'terms' => $terms,
    'field' => 'slug',
    'operator' => 'NOT IN'
    )
    ));
    }
    }
    }
    add_action('pre_get_posts', 'akv3_query_format_standard');