[wp-hackers] Custom Post Type in Admin, filter by new custom Taxonomies
Mike Schinkel
mikeschinkel at newclarity.net
Fri Jul 23 08:46:13 UTC 2010
Sorry, I forgot there's something else needed in your use-case. Try adding this (I think it will work):
add_action( 'request', 'my_request' );
function my_request($request) {
if (is_admin() && $GLOBALS['PHP_SELF'] == '/wp-admin/edit.php' && isset($request['post_type']) && $request['post_type']=='ressource_fr') {
$request['taxonomy'] = 'classement-fr';
$request['term'] = get_term($request['classement-fr'],'classement-fr')->name;
unset($request['name']);
}
return $request;
}
There actually may be an easier way (I really hope there is) and if so others please tell me.
-Mike
On Jul 23, 2010, at 4:24 AM, Jimmy Roy wrote:
> finally no... the result is still the same, when I click on filter : "no
> result".
>
> Jimmy
>
>
> 2010/7/23 Jimmy Roy <jimmy.roy at gmail.com>
>
>> the generated code is :
>>
>> <select class="postform" id="cat" name="classement-fr">
>> <option selected="selected" value="0">Afficher tout</option>
>> <option value="5" class="level-0">Langue oral (4)</option>
>> <option value="6" class="level-1"> Niveau
>> 1 (2)</option>
>> <option value="7" class="level-1"> Niveau
>> 2 (1)</option>
>> <option value="8" class="level-1"> Niveau
>> 3 (1)</option>
>> </select>
>>
>> the id is "cat", like if a regular category, so I add the name parameter
>> in wp_dropdown_categories and assign to this parameter the query_var value
>> of the custom taxonomy :
>>
>> wp_dropdown_categories( 'show_option_all=Afficher
>> tout&show_count=1&hierarchical=1&taxonomy=classement_fr&name=classement-fr');
>>
>> now when I click on filter... the result is always all my ressources !
>>
>>
>> --
>> Jimmy | www.jimmyroy.fr
>> --
>>
>>
>>
>> 2010/7/23 Jimmy Roy <jimmy.roy at gmail.com>
>>
>> thank u Mike and Scribu, I wrote a mix of your solutions :
>>>
>>> add_action( 'restrict_manage_posts', 'my_restrict_manage_posts' );
>>>
>>> function my_restrict_manage_posts() {
>>> global $typenow;
>>> if ($typenow=='ressource_fr')
>>> wp_dropdown_categories( 'show_option_all=Afficher
>>> tout&show_count=1&hierarchical=1&taxonomy=classement_fr');
>>> }
>>>
>>> but when I click on 'filter' the result is always ... "no result".
>>>
>>> Jimmy
>>>
>>>
>>> 2010/7/23 Mike Schinkel <mikeschinkel at newclarity.net>
>>>
>>> On Jul 23, 2010, at 3:35 AM, scribu wrote:
>>>>>> Are you sure? Unless I misunderstand what Jimmy is asking I think it
>>>> can
>>>>>> be done in the "restrict_manage_posts" hook.
>>>>>
>>>>> Indeed. Also, he can use wp_dropdown_categories() instead of creating
>>>> the
>>>>> select manually.
>>>>
>>>> Thanks. :)
>>>>
>>>> No matter how hard I try, I can't keep track of every function in the
>>>> library! Maybe the new 3.org will help.
>>>>
>>>> -Mike
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>
>>>
>>>
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list