How to get a custom taxonomy slug in body classes

To add the custom taxonomy slug to the body classes of your WordPress site, you can use the body_class filter along with your custom code. Below is your example of how you can achieve this: function themeprefix_add_taxonomy_class($classes) { global $post; if (is_page()) { $taxonomy = ‘page_section’; $terms = get_the_terms($post->ID, $taxonomy); if ($terms && !is_wp_error($terms)) { … Read more

How reorder post tags taxonomy in the non-alphabetical custom order and save it in the Block Editor

To reorder post tags taxonomy in a non-alphabetical custom order and save it in the Block Editor To achieve results use a combination of custom code. // Custom function to fetch tags in custom order function custom_get_tags($post_id) { $tags = get_the_tags($post_id); // Modify $tags array to reorder based on custom order // Your custom ordering … Read more

Filter on one post type with taxonimy and get other post type

tax_query with an ‘OR’ relation. This means that the query will fetch posts that meet either condition: they are ‘landing-pages’ with the specified taxonomy terms, or they are any of the other specified post types without additional taxonomy constraints. $args = array( ‘posts_per_page’ => 6, ‘post_status’ => ‘publish’, ‘order’ => ‘DESC’, ‘post_type’ => array(‘news’, ‘videos’, … Read more