Search
 
SCRIPT & CODE EXAMPLE
 

PHP

restrict_manage_posts hook

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
add_action( 'restrict_manage_posts', 'my_post_type_filter', 10, 2 );
function my_post_type_filter( $post_type, $which ) {
    if ( 'my-post' !== $post_type ) {
        return; //check to make sure this is your cpt
    }
 
    $taxonomy_slug = 'my-post-type';
    $taxonomy      = get_taxonomy($taxonomy_slug);
    $selected      = '';
    $request_attr  = 'my_type'; //this will show up in the url
  
    if ( isset( $_REQUEST[ $request_attr ] ) ) {
        $selected = $_REQUEST[ $request_attr ]; //in case the current page is already filtered
    }
     
    wp_dropdown_categories(array(
        'show_option_all' =>  __("Show All {$taxonomy->label}"),
        'taxonomy'        =>  $taxonomy_slug,
        'name'            =>  $request_attr,
        'orderby'         =>  'name',
        'selected'        =>  $selected,
        'hierarchical'    =>  true,
        'depth'           =>  3,
        'show_count'      =>  true, // Show number of post in parent term
        'hide_empty'      =>  false, // Don't show posts w/o terms
    ) );
}
Comment

PREVIOUS NEXT
Code Example
Php :: converting php to codeigniter 
Php :: Mirror Inverse Program in php 
Php :: movies -inurl:(htm|html|php|pls|txt) intitle:index.of “last modified” (mp4|wma|aac|avi) 
Php :: Storing login info in a session 
Php :: type declaration php 
Php :: csv import laravel 
Php :: How to post a mutlipart file using file_get_contents in php 
Php :: php radian to cosine 
Php :: traduction website with i18n 
Php :: radio button in php form 
Php :: echo two variables same line php 
Php :: limit query laravel 
Php :: PHP detect spam name 
Php :: php mysql text mark question 
Php :: php preg_match html cross origin 
Php :: random record get with pagination in karavel 8 
Php :: implement class in autoloader athow to implment data table in laravel project 
Php :: sorting table row data with php 
Php :: how to create php message 00 
Php :: md5_file (PHP 4 = 4.2.0, PHP 5, PHP 7, PHP 8) md5_file — Calculates the md5 hash of a given file 
Php :: extension gd missing laravel composer update 
Php :: laravel handle image validation 
Php :: laravel import csv 
Php :: laravel belongsto with condition date 
Php :: php pop up message 
Php :: 16 digit random password generator php code without function 
Php :: WP Admin Bar Dev Links 
Php :: standalone laravel orm 
Php :: condition for both of one should be true laravel eloquent 
Php :: send parameter to function in php can null 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =