• I’ve setup a filter on the backend to filter a post type by a taxonomy. The problem is once the filter is used the drag and drop feature dissapears.

    Here is the code I used to add the dropdown filter:

    /**

    • Display a custom taxonomy dropdown in admin
      / add_action(‘restrict_manage_posts’, ‘tsm_filter_post_type_by_taxonomy’); function tsm_filter_post_type_by_taxonomy() { global $typenow; $post_type = ‘curriculum’; // change to your post type $taxonomy = ‘lesson-type’; // change to your taxonomy if ($typenow == $post_type) { $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ”; $info_taxonomy = get_taxonomy($taxonomy); wp_dropdown_categories(array( ‘show_option_all’ => sprintf( __( ‘Show all %s’, ‘textdomain’ ), $info_taxonomy->label ), ‘taxonomy’ => $taxonomy, ‘name’ => $taxonomy, ‘orderby’ => ‘name’, ‘selected’ => $selected, ‘show_count’ => true, ‘hide_empty’ => true, )); }; } /*
    • Filter posts by taxonomy in admin
      */
      add_filter(‘parse_query’, ‘tsm_convert_id_to_term_in_query’);
      function tsm_convert_id_to_term_in_query($query) {
      global $pagenow;
      $post_type = ‘curriculum’; // change to your post type
      $taxonomy = ‘lesson-type’; // change to your taxonomy
      $q_vars = &$query->query_vars;
      if ( $pagenow == ‘edit.php’ && isset($q_vars[‘post_type’]) && $q_vars[‘post_type’] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) {
      $term = get_term_by(‘id’, $q_vars[$taxonomy], $taxonomy);
      $q_vars[$taxonomy] = $term->slug;
      }
      }


    Should I be adding anything to this so that it works properly with Post Types Order?

  • You must be logged in to reply to this topic.