• Resolved dumboxp

    (@dumboxp)


    Dear Greg, It would be great to optionally hide (or overwrite) the price for ads that have been sold.

    It could be implemented quite similarly to the existing options to “Hide contact details (or contact form) for ‘sold’ Ads.” and an optional string like “Top/bottom Notification Text”.

    Background: Many users are fine that their sold ads are still listed for a while but want to ensure that they cannot be contacted AND that the price is not shown anymore.

    Playing around with CSS once worked but this is always a bad workaround.

    best, Roland

    • This topic was modified 1 year, 1 month ago by dumboxp.

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

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

    (@gwin)

    Hi,

    you can do that by adding the code below in your theme functions.php file or even better by creating a new blank plugin (https://wpadverts.com/blog/how-to-use-code-snippets-in-wordpress/) and pasting it there

    add_filter( "adverts_get_the_price", function( $price, $price_raw, $post_id ) {
        $sold = get_post_meta( $post_id, "marked_as_sold", true );
        if( $sold == "1" ) {
            return "[hidden]";
        } else {
            return $price;
        }
    }, 10, 3 );

    For “sold” ads the price should be replaced with “[hidden]” text, if you want to show some other text just update it in the code above.

    Thread Starter dumboxp

    (@dumboxp)

    Thanks for your quick answer! The snippet works perfectly! ?

    I would appreciate if you integrate these kind of useful snippets into the plugins one day.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Mark as Sold: hide or overwrite the price of sold ads’ is closed to new replies.