• Resolved feijon

    (@feijon)


    Hello, we are interested in acquiring the WPAdverts plugin, however, we need to use “new” and “used” badges in all our ads in the upper left corner, as we must proceed to have this function in the WPAdverts plugin.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    i understand you will have some custom field which will allow you to select “new” or “used” option (let’s assume this field will be named “condition”).

    If so then you can display the badge like on the page you linked to by adding the code below in your theme functions.php file

    
    add_action( "adverts_list_after_title", "my_adverts_list_after_title" );
    function my_adverts_list_after_title( $post_id ) {
        $cond = get_post_meta( $post_id, "condition", true );
        if( $cond == "new" ) {
            echo '<span style="display:inline-block;float:right;position: absolute;top: 5px;left: 5px;background: blue;color: white;padding: 2px 4px;font-size: 12px;">NEW</span>';
        } else {
            echo '<span style="display:inline-block;float:right;position: absolute;top: 5px;left: 5px;background: yellow;color: white;padding: 2px 4px;font-size: 12px;">USED</span>';
        }
    }
    
Viewing 1 replies (of 1 total)

The topic ‘Badge’ is closed to new replies.