• Resolved pritty

    (@pritty)


    Hi,

    How i can add custom badge image based on post meta data.

    I want to add below condition in post featured image: I want to add badge top of featured image

    $premium = get_post_meta($post->ID, "premium", true);

    if (!is_admin() && !empty($premium) && (!is_single())) {

    $badge_html .= '<style>.badge {

    position: absolute;

    top: 0px;

    width: 80px;

    font-size: 12px;

    }

    @media (max-width: 768px) {

    .badge {

    font-size: 10px;

    }

    }

    </style><span class="badge"><img src="https://www.debunschoter-online.nl/wp-content/uploads/2022/04/premium_large1.jpg"/></span>';

    }

    // Sponsor badge

    $sponsor = get_post_meta($post->ID, "sponsor", true);

    if (!is_admin() && !empty($sponsor) && (!is_single())) {

    $badge_html .= '<style>.badge2 {

    position: absolute;

    top: 0px;

    width: 80px;

    font-size: 12px;

    }

    @media (max-width: 768px) {

    .badge2 {

    font-size: 10px;

    }

    }

    </style><span class="badge2"><img src="https://www.debunschoter-online.nl/wp-content/uploads/2024/06/gesponserd.png"/></span>';

    }

    // Video badge

    $video1 = get_post_meta($post->ID, "video1", true);

    if (!is_admin() && !empty($video1) && (!is_single())) {

    $badge_html .= '<style>

    .badge1 {

    position: absolute;

    top: 0px;

    width: 80px;

    font-size: 12px;

    right: 0px;

    }

    @media (max-width: 768px) {

    .badge1 {

    font-size: 10px;

    }

    }

    </style><span class="badge1"><img src="https://www.debunschoter-online.nl/wp-content/uploads/2024/06/video.png"/></span>';

    }
Viewing 1 replies (of 1 total)
  • Hi there,
    I’ve discussed the badge on featured images with our developer, and unfortunately, there are a few complex scenarios involved.

    As a result, we are unable to accept this as a feature request at this time.
    Thank you for your understanding.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.