1. Home
  2. ReHub Theme
  3. Advanced tips and customizations
  4. Automatically set post badge

Automatically set post badge

All posts and products can have custom badges. Here also some snippets how to automatically assign badges.

Assign badge when post reaches +100 hot/thumb counter

add_action('rh_overall_post_likes_add', 'set_badge_hot_counter');
function set_badge_hot_counter(){
   $post_id = intval( $_POST['post_id'] );
   $hotcount = get_post_meta($post_id, 'post_hot_count', true);
   if($hotcount && $hotcount > 100){
      update_post_meta($post_id, 'is_editor_choice', 1);

This code will change post Badge to First Badge. By default, it’s “Editor Choice” Badge, but you can set own in theme option – custom badges

If you want to set second badge, set 2 in last line. If you want to use this code for wishlist counter, change post_hot_count in code to post_wish_count and rh_overall_post_likes_add to rh_overall_post_wishes_add

How to customize your theme