Custom taxonomy filter for media

You can add the taxonomy parameter. function add_image_category_filter() { $screen = get_current_screen(); if ( ‘upload’ == $screen->id ) { $dropdown_options = array( ‘taxonomy’ => ‘YOUR_TAXONOMY’, ‘show_option_all’ => __( ‘View all categories’, ‘iCats’ ), ‘hide_empty’ => true, ‘hierarchical’ => true, // default is cat which wouldn’t filter custom taxonomies ‘value_field’ => ‘slug’, ‘name’ => ‘YOUR_TAXONOMY’, ‘orderby’ … Read more

WordPress custom permalink and archive link for custom post type

You need to either go into Settings -> Permalinks and click Save Or if you’re doing this programmatically you need to use flush_rewrite_rules(), but make sure this is only used when you activate/deactivate the plugin, DON’T set this in code that runs (like in init, or on every page load): https://developer.wordpress.org/reference/functions/flush_rewrite_rules/ register_deactivation_hook( __FILE__, ‘flush_rewrite_rules’ ); … Read more

delete term from taxonomy and assign in new one

wp_update_term() doesn’t changes taxonomy. It just updated the existing taxonomy. Say the below code- $update = wp_update_term( 1, ‘category’, array( ‘name’ => ‘Uncategorized Renamed’, ‘slug’ => ‘uncategorized-renamed’ ) ); if ( ! is_wp_error( $update ) ) { echo ‘Success!’; } This code finds the category which ID is 1, then updates it to the name … Read more

Loop through custom taxanomy in post and display custom fields from posts

You are going to need set up a new WP_Query in your content-*.php with the correct parameters in order to send it into a loop. <?php $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘recipes’,. ‘field’ => ‘slug’, ‘terms’ => ‘dessert’ ))); $your_posts = new WP_Query( $args ); ?> You can add any other … Read more

How to get attached image to taxonomy..?

If your going to reference the uploads directory use https://developer.wordpress.org/reference/functions/wp_upload_dir/ <?php $upload_dir = wp_upload_dir(); // Array of key => value pairs /* $upload_dir now contains something like the following (if successful) Array ( [path] => C:\path\to\wordpress\wp-content\uploads\2010\05 [url] => http://example.com/wp-content/uploads/2010/05 [subdir] => /2010/05 [basedir] => C:\path\to\wordpress\wp-content\uploads [baseurl] => http://example.com/wp-content/uploads [error] => ) // Descriptions [path] – … Read more