Im trying to add a div for just one category

To wrap the thumbnail wit I would do something like this: First. Create the expire class string $expire_class = in_category(‘expired’) ? ‘expire’ : ”; Then, wrap your post thumbnail code with this: <div class=”<?php echo $expire_class; ?>” > [put your thumbnail code here] </div> So, it looks like this: <?php $expire_class = in_category(‘expired’) ? ‘expire’ … Read more

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