Custom taxonomy archive – No posts found [closed]

Remember that you must always go to the Page “Settings” -> “Permalinks” and refresh your permalink structure after you add both the Quote Post Type and the Category Taxonomy in your code, otherwise there is no regex with this pattern. Here I’ve got this URL: http://localhost/quotes/category/dev Because you’ve set the rewrite slug to “quotes/category”. But … Read more

How to output the taxonomy term name in a widget

Check the properties of get_queried_object(). Sample code: <?php # -*- coding: utf-8 -*- /** * Plugin Name: Current Term Widget */ add_action( ‘widgets_init’, array ( ‘Current_Term_Widget’, ‘register’ ) ); class Current_Term_Widget extends WP_Widget { public function __construct() { parent::__construct( ‘current_term’, ‘Current Term’ ); } public function widget( $args, $instance ) { if ( isset ( … Read more

Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?

There is no way easy way to do that. You have to query directly to achieve that. I am assuming, you only want the parent categories which don’t have descendants or even if they have descendants, it’s not used in any post global $wpdb; $categories = $wpdb->query(“SELECT $wpdb->terms.* FROM $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id … Read more

Adding session variable and/or cookie based on user-selected input

You can definitly use PHP session variables. Follow this blog post (“Listing 3”) for the best way to enable PHP sessions in WordPress. Namely, you need to use this code in your plugin or in your theme’s funtions.php: add_action( ‘init’, ‘session_start’, 0 ); After that you can use basic session variables to set the country … Read more

How do I display a tag cloud with both post tags AND a custom taxonomy?

The following is a slightly modified version of the wp_tag_cloud() function: function custom_wp_tag_cloud( $args=”” ) { $defaults = array( ‘smallest’ => 8, ‘largest’ => 22, ‘unit’ => ‘pt’, ‘number’ => 45, ‘format’ => ‘flat’, ‘separator’ => “\n”, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘exclude’ => ”, ‘include’ => ”, ‘link’ => ‘view’, ‘taxonomy’ => ‘post_tag’, … Read more

Retrieve taxonomy terms in order of their post’s date?

I would use the terms_clauses filter, and then just use get_terms(): function wpse147412_order_terms_by_post_date( $pieces, $taxonomies, $args ) { global $wpdb; if ( ‘post_date’ !== $args[‘orderby’] ) { return $pieces; } $args = wp_parse_args( $args, array( ‘post_types’ => ‘post’ ) ); $pieces[‘fields’] = ‘DISTINCT ‘ . $pieces[‘fields’]; $pieces[‘join’] .= ” JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id … Read more