Permalinks for quote authors

Create a custom taxonomy quoteauthor, activate pretty permalinks, and you get nice URIs automatically. These URIs will not put the author’s name right behind the root, but something like /qa/steve-stevenson/ should be good enough. Here is a sample code as a plugin, you can download it on GitHub <?php # -*- coding: utf-8 -*- /* … Read more

Post slider with custom post type

I don’t have enough rep to comment, but what does your actual query look like? Edit: I haven’t been able to test it, but I think this will work $args = array( ‘post_type’ => ‘slider’, ‘meta_key’ => ‘_thumbnail_id’, // only pull sliders with images ‘tax_query’ => array( array( ‘taxonomy’ => ‘slideshow’, ‘field’ => ‘slug’, ‘terms’ … Read more

drop-down list another query

Just a standard HTML form will do! <form action=”<?php echo home_url(“https://wordpress.stackexchange.com/”); ?>” method=”get”> <p><?php wp_dropdown_categories(‘taxonomy=taxonomy-1&name=taxonomy-1’); ?></p> <p><?php wp_dropdown_categories(‘taxonomy=taxonomy-2&name=taxonomy-2′); ?></p> <p><input type=”submit” value=”Search!” /></p> </form> Just replace taxonomy-1 and taxonomy-2 with the names of your taxonomies. Important If you registered your taxonomy with a custom query_var, you’ll need to match it in the name argument of … Read more

Adding Custom taxonomies to Press This panel

I assume you’re talking about Custom Post Type, not Custom Taxonomy. Right? If yes, add this code on your functions.php file: function press_this_ptype($link) { $post_type=”example”; $link = str_replace(‘post-new.php’, “post-new.php?post_type=$post_type”, $link); $link = str_replace(‘?u=’, ‘&u=’, $link); return $link; } add_filter(‘shortcut_link’, ‘press_this_ptype’, 11); Once you add the correct Post Type, WordPress will detect all taxonomies attached to … Read more

Get main term from a sub term in Woocommerce

code function wc_origin_trail_ancestor( $link = false, $trail = false ) { if (is_product_category()) { global $wp_query; $q_obj = $wp_query->get_queried_object(); $cat_id = $q_obj->term_id; $descendant = get_term_by(“id”, $cat_id, “product_cat”); $descendant_id = $descendant->term_id; $ancestors = get_ancestors($cat_id, ‘product_cat’); $ancestors = array_reverse($ancestors); $origin_ancestor = get_term_by(“id”, $ancestors[0], “product_cat”); $origin_ancestor_id = $origin_ancestor->term_id; $ac = count($ancestors); } else if ( is_product() ) { … Read more