Woocommerce change tag_id to name

You can use get_term() to get the full term objects which contain the name. If you do this in array_map() you can convert the IDs in the array to the name: $lob = $values[data]->tag_ids; $names = array_map( function( $term_id ) { $term = get_term( $term_id ); return $term->name; }, $lob );

Remove base category gives 404 error

Just enter “https://wordpress.stackexchange.com/” OR ‘.’ (without quotes) as the value for Category base. Seemed to work perfectly when I tested it. I’d be interested in hearing if anyone discovers other dangers to doing this, other than the obvious potential of collisions between posts, pages, and categories.

List posts from a category and embed them into a page

That’s certainly possible. Use WP_Query to search for posts, then output them as you please. For example, to get 20 posts from the category with the id 4: <?php $query = new WP_Query( array( ‘category__in’ => 4 ‘posts_per_page’ => 20 ) ); if ( $query->have_posts() ) { echo “Here are some posts from that category:”; … Read more

Get category from slug list

$category_slug_array = array(‘slug_1’, ‘slug_2’, ‘slug_2’); //array of category slugs foreach($category_slug_array as $category_slug){ $my_categories[] = get_term_by( ‘slug’, $category_slug, ‘category’); //getting category object by slug } print_r($my_categories); //printing array of categories

Get category id of next / prev post inside the_post_navigation

Here was my final solution: $next_post = get_next_post(); if (!empty( $next_post )){ $next_categories = get_the_terms($next_post->ID,’category’); $next_cat_data = get_option(‘category_’.$next_categories[1]->term_id); if (isset($next_cat_data[‘hex’])){ echo “<style>div.nav-next:hover{background-color:”.$next_cat_data[‘hex’].”;} div.nav-next:hover span.post-title, div.nav-next:hover span.meta-nav {color:#f8f7f4;}</style>”; } } $previous_post = get_previous_post(); if (!empty( $previous_post )){ $prev_categories = get_the_terms($previous_post->ID,’category’); $prev_cat_data = get_option(‘category_’.$prev_categories[1]->term_id); if (isset($prev_cat_data[‘hex’])){ echo “<style>div.nav-previous:hover{background-color:”.$prev_cat_data[‘hex’].”;} div.nav-previous:hover span.post-title, div.nav-previous:hover span.meta-nav {color:#f8f7f4;}</style>”; } }

Show Subcategory Name Instead of Parent Category

$terms = get_terms( [‘taxonomy’ => ‘some-taxonomy’, ‘parent’ => 123 ] ); // or $categories = get_categories( [ ‘parent’ => 123 ] ); Where the parent id is the one you want to get the subcategory from. This gives you all subcategories/-terms in an array. You can access data like name or term_id. For getting the … Read more