Create multiple taxonomies with custom fields values on the fly when creating new posts

This is the code I use to insert a list of taxonomy terms in a dedicated plugin category. On can also directly add the terms to the main post category. // ************** Add taxonomy $taxonomy_term = “my_term”; $taxonomy_category = “my_taxonomy_category”; if (null !==(get_the_ID())) { if ( taxonomy_exists( $taxonomy_category ) ){ // if the tag doesn’t … Read more

Filter language in Polylang for custom taxonomy

Nevermind, I finally found. This is not documented, but going through Polylang code I found a way. First retrieve the languages with their taxonomy id with $lang = get_terms(‘term_language’, [‘hide_empty’ => false]) which gives an object that can be called as $lang->name and $lang->term_id. Then, the wp_query should look like this: $args = array( ‘post_type’ … Read more

Reorder a page of posts of a certain taxonomy/value by a custom field

Well, I did it like this. Maybe it will help someone. add_filter( ‘pre_get_posts’, function () { global $wp_query; // article type – change posts per page. If webinars then change order to webinar_date if ( isset( $wp_query->query[‘article_type’] ) ) { set_query_var( ‘posts_per_page’, 12 ); if ( $wp_query->is_tax(‘article_type’, ‘webinar’) ) { $wp_query->set( ‘meta_key’, ‘webinar_date’ ); $wp_query->set( … Read more