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

Getting taxonomy terms used by custom post type

If you see doc for wp_list_categories in codex, you’ll se that it accepts a include param, that should contain a comma separed list of categorys ids. So if you change your function get_terms_by_post_type creating the function get_terms_id_by_post_type to retrieve only the term ids, just like: function get_terms_id_by_post_type( $taxonomies, $post_types ) { global $wpdb; $query = … 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

How to display recent posts added in custom post types

The answer is essentially in Codex! <h2>Recent Posts</h2> <ul> <?php $recent_posts = wp_get_recent_posts(array(‘post_type’=>’book’)); foreach( $recent_posts as $recent ){ echo ‘<li><a href=”‘ . get_permalink($recent[“ID”]) . ‘” title=”Look ‘.esc_attr($recent[“post_title”]).'” >’ . $recent[“post_title”].'</a> </li> ‘; } ?> </ul> The only thing I did was add an argument to search for the book post type instead of the default … Read more