Include Taxonomy slug in post url

Add Custom Taxonomy Tags to Your WordPress Permalinks What you wish to do is have your taxonomy available to use within the Permalink structure e.g. /%actor%/%postname% First you write your taxonomomy as you have already done, but you require additional fields: add_action(‘init’, ‘add_actor_taxonomy’); function add_actor_taxonomy() { if (!is_taxonomy(‘actor’)) { register_taxonomy( ‘actor’, ‘post’, array( ‘hierarchical’ => … Read more

Display only deepest category on a single post?

I come to this post as i was looking for the code. But the marked answer not working for me anymore. I have wrote a function to get the deepest level category assigned to a post. function post_deepest_level_cat($post_categories) { foreach ($post_categories as $category) { $cat_ids[] = $category->term_id; } $tree_args = array( ‘current_category’ => $cat_ids, ‘depth’ … Read more

get_post_terms not working as expected

I misunderstood what you were trying to do before. I thought you wanted to list the terms associated with one particular post – the one you are on. Whoops! Try this instead: $terms = get_terms(‘fruit_category’); if(!empty($terms)){ echo “<ul>”; foreach ( $terms as $term ) { echo ‘<li><a href=”‘.get_term_link($term->slug, ‘fruit_categories’).'”>’. $term->name . “</a></li>”; } echo “</ul>”; … Read more

How to show term-specific post list, without posts associated with child terms?

As @Milo’s pointer said, this: Sadly, is normal WordPress behaviour. Can be suppressed using parse_tax_query and include_children set at 0… The code found in the answer at https://wordpress.stackexchange.com/a/202773/39300 Works for me… function taxonomy_archive_exclude_children($query){ $taxonomy_slugs = [‘product_category’, ‘application_category’]; if($query->is_main_query() && is_tax($taxonomy_slugs)){ foreach($query->tax_query->queries as &$tax_query_item){ if(empty($taxonomy_slugs) || in_array($tax_query_item[‘taxonomy’], $taxonomy_slugs)){ $tax_query_item[‘include_children’] = 0; } } } } add_action(‘parse_tax_query’, … Read more

Get parent and first child taxonomy terms?

There is unfortunately no way that you are going to do this in one or two queries. It seems that there are a misunderstanding or misconception about database queries. The most important aspect to keep in mind when you are running database queries is the amount of database queries vs. the time these queries will … Read more

Add Thumbnail to wp_list_categories()

The original question uses get_tax_meta() which does not exist in WordPress core but may be a custom function created by the asker. In this case we could switch it out just as well with get_term_meta(). You could try this: class List_Category_Images extends Walker_Category { function start_el( &$output, $category, $depth = 0, $args = array(), $id … Read more

How to have “the most used tags” taxonomy always expanded?

There does not appear to be any way to hook into that from inside PHP http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/includes/meta-boxes.php#L300 So JavaScript will probably best suit as a quick and easy solution. add_action( ‘admin_footer-post-new.php’, ‘wpse_45149_inject_script’ ); function wpse_45149_inject_script() { $expand_for = array( ‘post_tag’ ); // add taxonomy names here // build a nice jQuery query foreach ( $expand_for as … Read more

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