• Resolved sellyk

    (@sellyk)


    Hello,
    I have 2 questions.
    1. Is there a way that I can display specific ads on ‘advert_list’ page . Like If i wanted to select specific ads by ID to be displayed on a page, in an order of my choosing, how I can I do that? Is there a shortcode that i can use to call only specific adverts id’s?

    2. On a single ad page, I want to change the word ‘by’ to something else. However I have not been able to. I tried creating a new new folder in my child theme like advised in one of your articles (instead of making changes on the original plugin itself). I then tried to change it on the core single.php file itself and despite changing ‘by’ no changes were reflected whatsoever on the frontend. I cleared the cache several times. I then even tried the text changes plugin and I was unsuccessful. Usually when I make changes to other parts of the plugin I manage, but this time simply changing one word has been a challenge. Kindly, what am I doing wrong? How can I make the change of ‘by’ to whichever word i please?

    Thanks in advance!

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

    (@gwin)

    Hi,
    1. you can add the code below in your theme functions.php file

    
    add_filter( "shortcode_atts_adverts_list", function(  $out, $pairs, $atts  ) {
        if( isset( $atts["post__in"] ) ) {
            $out["post__in"] = $atts["post__in"];
        } 
        return $out;
    }, 10, 3 );
    add_filter( "adverts_list_query", function( $args, $params ) {
        if( isset( $params["post__in"] ) ) {
            $args["post__in"] = array_map( "trim", explode( ",", $params["post__in"]) );
            $args["orderby"] = "post__in";
        }
        return $args;
    }, 10000, 2 );
    

    it will allow you using an [adverts_list] shortcode as [adverts_list post__in="100,200"] where 100 and 200 are IDs of posts you want to show. It will list the Ads in order in your post__in param, that is first the Ad with ID=100 then an Ad with ID=200 and so on.

    2. The best way to change the phrase without modifying original files is to use a plugin like Say What? https://www.ads-software.com/plugins/say-what/

    The phrase you will want to change is by <strong>%s</strong>, also when translating this phrase with Say What? make sure to enter in the “Text Domain” input a value “adverts” otherwise the phrase will not show as translated.

    Thread Starter sellyk

    (@sellyk)

    Hi Greg,

    Thank you for the code snippet, it worked perfectly.

    As for the Text change, i already had the plugin, but it seems i was failing to put in the complete phrase. Thank you for giving me the correct phrase.

    I appreciate the help!

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    ok great, i am marking this thread as resolved then :).

    BTW. If you are finding the plugin useful i would be thankful if you could write a short one or two sentence review here https://www.ads-software.com/support/view/plugin-reviews/wpadverts

    Hi Greg, i want to ask, how to change “Your ad has been published. You can view it here(Url…)” and also text when ad is going to moderation, – to another text, with the help of “say what” I cant find right text domain (“adverts” as domain – dont work)?

    Plugin Author Greg Winiarski

    (@gwin)

    You can translate this phrase using Say What? The text-domain is “adverts”, and the phrase to translate is

    
    'Your ad has been published. You can view it here "<a href="%1$s">%2$s</a>".'
    

    If you cannot do it with Say What? you can use a plugin like Loco Translate and do an English to English translation, that is just translate/modify the phrases you want to change.

    Thanks, it works with Say What?, (just without ‘ ‘ only: Your ad has been published. You can view it here “link here”.)

    • This reply was modified 5 years, 6 months ago by densdj.
    • This reply was modified 5 years, 6 months ago by densdj.
    • This reply was modified 5 years, 6 months ago by densdj.
    Plugin Author Greg Winiarski

    (@gwin)

    Ok, great, it actually should be without the ' chars at the beginning and the end, i copied them accidentally, sorry.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display Specific Ads + Unable to Change Text’ is closed to new replies.