Badges Appearing in Latest Listings Widget?
How can I VIP badges appear for the Latest Listings widget please?
PHP Code:
function my_cp_add_listing_item_featured() {
// Only show on archive pages.
// Category, Author, Listing Post Types, Listing Search, etc.
if ( ! is_archive() ) {
return;
}
// Change the list of addons according to your case.
// NOTE: get the Addon type on the addon page under the Slug box.
$addons_types = array(
'ad_listing-highlight' => __( 'Highlight', 'yourdomain' ),
'ad_listing-vip' => __( 'VIP', 'yourdomain' ),
'ad_listing-urgent' => __( 'Urgent', 'yourdomain' ),
'ad_listing-good-price' => __( 'Good Price', 'yourdomain' ),
'ad_listing-tipp' => __( 'Tipp', 'yourdomain' ),
'ad_listing-featured' => __( 'Featured', 'yourdomain' ),
);
$labels = '';
// Go through all addons above and add a label HTML.
foreach ( $addons_types as $addon_type => $label ) {
if ( appthemes_has_addon( get_the_ID(), $addon_type ) ) {
$labels .= '<span class="featured-label label featured-label-' . $addon_type . '">' . $label . '</span>';
}
}
if ( ! empty( $labels ) ) {
echo html( 'div class="featured-label-wrap" style="position:absolute;top:0;line-height:0.9;"', $labels );
}
}
add_filter( 'cp_listing_item_head', 'my_cp_add_listing_item_featured', 8 );
Add it to appropriate Addon setting or in the Additional CSS section of the Customizer:
Code:
Code:
.featured-label.featured-label-ad_listing-highlight {
position:initial;
background: #F8AC59;
color: #FEFEFE;
margin-right: 5px;
}