gcacciola
Forum Replies Created
-
Alright, its best to leave people without solutions. 3 months with no answer is fine.
Lol, I can’t either. I’ll post the code here. Whatever.
The plugin is to filter a custom post type called WIKI, and i want to filter it by the taxonomy called wiki-category.
I hope it helps.
<?php
/**
* Plugin Name: Categoria-Wiki
* Display a custom taxonomy dropdown in admin
* @author Mike Hemberger
* @link https://thestizmedia.com/custom-post-type-filter-admin-custom-taxonomy/
*/
add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy');
function tsm_filter_post_type_by_taxonomy() {
global $typenow;
$post_type = 'wiki'; // change to your post type
$taxonomy = 'wiki-category'; // 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' => __("Show All {$info_taxonomy->label}"),
'taxonomy' => $taxonomy,
'name' => $taxonomy,
'orderby' => 'name',
'selected' => $selected,
'show_count' => true,
'hide_empty' => true,
));
};
}
/**
* Filter posts by taxonomy in admin
* @author Mike Hemberger
* @link https://thestizmedia.com/custom-post-type-filter-admin-custom-taxonomy/
*/
add_filter('parse_query', 'tsm_convert_id_to_term_in_query');
function tsm_convert_id_to_term_in_query($query) {
global $pagenow;
$post_type = 'wiki'; // change to your post type
$taxonomy = 'wiki-category'; // 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;
}
}
jtrip how experienced is you with coding and wordpress? I am no coder but I am great at googling and copying and pasting codes hahaha.
I had no answer but I ended up “adapting” the code for my own needs.
If you think you can do it, send me a PM and I’ll send you what I did, but you’ll have to adapt yourself.
I hope it helps.
Its crazy that no one even answers this! I understand it might be something like a security issue with spamming and such, but in our case it is for an intranet. I will have it paused for a while until I find a solution. I’ll let you know if we figure it out.
Hello, I am looking for the same solution, did you get it to work? Thank you.
Forum: Plugins
In reply to: [Postie] Posted “trigger”Wow Allen, thanks for the very quick response.
Well, if it is working for you, I’ll have to figure it out then. It seemed so clear.
Back t? testing.Regards
Giacomo