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

Custom taxonomy term as class?

You could do something like this <?php $terms = get_the_terms( $post->ID, ‘taxonomy_name’ ); ?> <div class=”myclass<?php foreach( $terms as $term ) echo ‘ ‘ . $term->slug; ?>”> <!– content –> </div> http://codex.wordpress.org/Function_Reference/get_the_terms

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

Listing child terms of parent term

When you are on a taxonomy page, you can get the parent from the term being displayed by using the following code with get_queried_object. See get_terms for the objects that are returned $queried_object = get_queried_object(‘term’); $term = $queried_object->parent; To get the taxonomy, you can simply just add $tax = $queried_object->taxonomy; below the code above. This … Read more

Hierarchical display of custom taxonomy

The wpse244577_list_terms() function below uses wp_list_categories() to do the heavy lifting, then modifies the results so that the terms are in reverse order of the hierarchy. Place this code in a plugin or your theme’s functions.php file: /** * Lists term links for a taxonomy in reverse order of hierarchy * * Based on https://developer.wordpress.org/reference/functions/wp_list_categories/#comment-1169 … Read more

get_the_term_list without specific category

I believe that what you want is to exclude a term. It is odd that such is not an option with that function but you can use a filter on get_the_terms: function exclude_my_term($terms, $post, $taxonomy) { remove_filter(‘get_the_terms’,’exclude_my_term’,10,3); unset($terms[123]); // where 123 is the ID of the term to exclude return $terms; } add_filter(‘get_the_terms’,’exclude_my_term’,10,3); You probably … Read more

Filtering more than one term in a taxonomy in WP

You can use tax_query and use the AND condition: Reference: WP_Query under Taxonomy Parameters $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘hotels’, ‘field’ => ‘slug’, ‘terms’ => array( ‘1 Star’ ) ), array( ‘taxonomy’ => ‘location’, ‘field’ => ‘slug’, ‘terms’ => array( ‘loc1’ ) ) ) ); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)