Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hwkdev/639944bc8bc21efcc31abf0958be1989 to your computer and use it in GitHub Desktop.

Select an option

Save hwkdev/639944bc8bc21efcc31abf0958be1989 to your computer and use it in GitHub Desktop.

Revisions

  1. hwkdev created this gist May 10, 2018.
    28 changes: 28 additions & 0 deletions wp-dynamic-taxonomy-query-template-example.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    <?php

    // Taxonomy
    add_action('init', 'hwk_taxonomy_tax_example_register');
    function hwk_taxonomy_tax_example_register() {
    register_taxonomy('tax_example', array('example'), array(
    'label' => __('Tax Example'),
    'hierarchical' => false,
    'public' => true
    ));
    }

    // Args: Remove Single View
    add_filter('hwk/taxonomy/tax_example/args/no_single', '__return_true');

    // Query
    add_filter('hwk/taxonomy/tax_example/query', 'hwk_taxonomy_tax_example_query');
    function hwk_taxonomy_tax_example_query($query){
    $query->set('posts_per_page', -1);
    $query->set('order', 'ASC');
    return $query;
    }

    // Template
    add_filter('hwk/taxonomy/tax_example/template', 'hwk_taxonomy_tax_example_template');
    function hwk_taxonomy_tax_example_template(){
    return 'templates/tax_example/archive.php';
    }