Daily Code: Day 2 – Show Me…. Bananas!

Daily Code: Day 2 – Show Me…. Bananas!

Daily Code: Day 2 – Show Me…. Bananas!

Going Bananas for Day 2 of Daily Code!

Simple WordPress Shortcode

Here is a quick one for today. A custom WordPress shortcode to display an inline image. In this case….. BANANAS!

This is something I wanted to have on KingKode for whenever I wanted to use it. Like right here [bananas].

All lines below are added at the very bottom of functions.php.

Callback Function:
function show_me_bananas() {
   $image = "<img class='bananas' src='/images/banana-icon.png'/>";
   return $image;

First, we need a function that spits out the image markup. The above sets the img markup as variable $image. Then returns the variable string when fired.

Register Shortcode Function:
function register_new_shortcodes(){
   add_shortcode('bananas', 'show_me_bananas');

Then, we need to link the previous function to a shortcode. add_shortcode() registers the show_me_bananas() function to the shortcode [bananas]. Note: you can register many other shortcodes with this function.

Hook into WordPress:
add_action( 'init', 'register_new_shortcodes');

Finally, WordPress needs to know that we have a new shortcode. add_action() gets fired when the page is initializing. register_new_shortcodes() is then added to the initialization process and, thus, your shortcodes have been registered.

Oh, yeah… The CSS:
.bananas {
display: inline-block;
margin: 0px 2px;

The CSS can be put at the very bottom of stylesheet.css. display: inline-block tells the image to be treated like a block element while inline with the text. margin: 0px 2px adds spacing on either side of the bananas for kerning purposes.

And now we have bananas! [bananas][bananas][bananas][bananas][bananas][bananas][bananas]

Join the Conversation

Loading Facebook Comments ...

106 thoughts on “Daily Code: Day 2 – Show Me…. Bananas!

  1. AvatarKickass

    It’s actually a nice and helpful piece of info. I am glad that you simply shared this helpful info with us.
    Please stay us informed like this. Thank you for sharing.

  2. Avatar피나클

    Hey There. I found your blog using msn. This
    is a really well written article. I will make sure to bookmark it and return to
    read more of your useful information. Thanks for
    the post. I’ll certainly return.

  3. Avatarhttps://pbase.com/

    Letting the blocks to the chain using a cryptocurrency is
    outperforming conventional stock market. Barclaycard refunded the £9,
    500 with out forex nobody cannot proceed their life by
    denying the existence of cryptocurrency. In lots of points let have changed their
    cash again into your currency for trading. Though Bitcoin trading system anyone can covert digital currency to a different facet of.

    Fb aims to navigate and find numerous instruments and indicators
    that a trading system and for that. Later on the prices rise or fall at a certain job inside the system.
    Nonetheless every hub in the system allows transactions to be
    modern enough to. These fee gateways facilitate faster validation of
    transactions from the community should be on-line all the time.
    Beneath completely different users need to buy items from ecoms and
    on-line payment gateways. I spoke to your electronic mail these will need you by means of
    instance most exchanges should have. Bitcoin surpasses the 10,000 hindrance on the market
    you’ll face no dearth of.

  4. Avatarsicbo

    Thank you for the good writeup. It in reality was once
    a entertainment account it. Look complicated to more introduced agreeable from you!

    By the way, how can we keep up a correspondence?

  5. Avatarhttp://iatwe.com/

    Using cryptocurrencies the place they have used the very best web sites to solicit Bitcoin donations.
    Citizens However are considered volatile and engaging user onboarding which ensures
    Ecoin to be the very best thought. The person closed an enormous amount
    of positions at market price without considering.
    First you need to log of activities person activities must
    be secure https slightly than use the. Needles to say utilizing press launch
    to the excessive volatility of the first Bitcoin. Might the ascent of Bitcoin estimates of which is the best and the.

    Others supply particular things you may take the printout of your public e mail.
    We should keep away from prices faster velocity might gain reputation over
    time a large number of websites. O safety by quietly accumulating a large motivated
    and Technologically savvy person-base of hosting as well.
    Extra helpful options a 1 click on the hyperlink to
    net site is present proper right here known.

  6. Avatarwords for wp

    Attractive section of content. I just stumbled upon your web
    site and in accession capital to assert that I acquire in fact enjoyed account your blog posts.
    Any way I’ll be subscribing to your feeds and even I achievement you access consistently fast.

  7. Avatarpandora outlet

    80% Off On mythical being Charms jewellery.
    benefit of special sale costs for the pandora charms rings and
    jewellery you love.
    Pandora charms Silver jewellery Outlet eightieth Off.
    lovely mythical being handcrafted rings, earrings, and necklaces at
    outlet discount costs.
    Shop these Last probability styles. mythical being
    Outlet eightieth Off now. mythical being outlet sales hugh
    discount. Explore additional pandora Pandora Charms deals.Pandora Outlet Sales|Shop pandora Up to 80th Off pandora Sale‎.
    New Arrivals on the official Pandora. 80 Off mythical being Charms
    deals. PANDORA® jewelry and Charms.

  8. Avataraff login mobile

    Hmm is anyone else experiencing problems with the pictures on this
    blog loading? I’m trying to determine if its a problem on my
    end or if it’s the blog. Any responses would be
    greatly appreciated.

  9. Avatarlookbook.nu

    Demonetization for info Thus voiding Bitcoin funds out of
    your paper money is an example. Binance for example moved from Hong Kong to
    Malta in response to regulatory adjustments. By tracking down these adjustments should switch
    belongings from individual to individual trading. Traders greatest bet is to bring an financial platform for
    online trading and transacting. Must fulfill very small opportunity to draw traders doing Bitcoin buying and selling or any.
    Bitcoin firstly function this kind to the other when it’s
    excessive. Multi-signature characteristic of others are
    very different with various fashions of safety to it.
    Hardware wallets and multi-signature transactions per day
    so your wallet could not count new funds/spendings into.
    All of the sudden in the previous efficiency of wallets
    that may be made in the. Again toward it was so risky and prices can change the password of.

    A significant improve in the costs in final decade cryptocurrency has emerged in. The database because the immense popularity of cryptocurrency are getting
    before you begin mining. New altcoins are helping to
    resolve varied problems with their specialized purposeful functions.
    Tons of of altcoins with ease restrictions on the foreign money of selection for drug deals and brokers.
    Remove national forex as compare to the Bitcoion Atm’s is quite accepted.

  10. Avatarsportsbets

    Just want to say your article is as astounding.
    The clearness to your publish is just great and i could think you’re an expert on this
    subject. Fine along with your permission allow me to grab your
    RSS feed to stay up to date with coming near near post.
    Thank you one million and please carry on the
    rewarding work.

  11. AvatarKattemalt i tube

    I like the valuable information you provide in your articles.

    I will bookmark your weblog and check again here frequently.
    I’m quite sure I’ll learn many new stuff right here! Good luck for the next!

  12. Avatarhttps://www.beyondtrust.com/search?ss360Query=www.nubobeauty.com

    Undeniably believe that that you stated. Your favourite reason seemed to be at the internet the simplest
    thing to be aware of. I say to you, I certainly get annoyed at the same time as
    people consider concerns that they just do not realize about.
    You managed to hit the nail upon the top as well as defined
    out the entire thing without having side-effects , other people
    could take a signal. Will probably be back to get
    more. Thank you

  13. AvatarBeauty

    Wow, marvelous weblog structure! How long have you been blogging for?
    you make blogging look easy. The whole glance of your
    web site is fantastic, as neatly as the content material!

  14. Avatarsocial media

    First of all I want to say awesome blog! I had a quick
    question which I’d like to ask if you don’t mind. I was interested to know how you center yourself and clear your mind prior to writing.

    I have had a hard time clearing my thoughts in getting my ideas out.
    I truly do enjoy writing but it just seems like the first 10 to 15 minutes tend
    to be wasted just trying to figure out how to begin. Any recommendations or hints?


  15. AvatarCecila

    I’m amazed, I have to admit. Rarely do I come across a blog that’s both equally educative and amusing, and let me tell
    you, you have hit the nail on the head. The issue is something that not enough folks are speaking intelligently about.

    I am very happy that I stumbled across this during my search for something relating to this.

  16. Avatarfriendly mutton chops beard

    Hello I am so thrilled I found your weblog, I really found you by accident, while I was
    researching on Bing for something else, Anyways I am here now and would just like to say thanks a lot
    for a remarkable post and a all round thrilling blog (I also love the theme/design), I don’t have time to browse it all at the
    moment but I have book-marked it and also included your RSS feeds, so when I have time I will be back to read more, Please do keep up the superb job.

  17. AvatarVonnie

    It is really a great and useful piece of info.
    I’m glad that you just shared this helpful information with
    us. Please keep us up to date like this. Thank you for sharing.

  18. Avatarreal vs fake art acnl

    Hey I am so delighted I found your web site, I really
    found you by mistake, while I was researching on Aol for something else, Regardless I am here now and would just
    like to say cheers for a remarkable post and
    a all round exciting blog (I also love the theme/design), I don’t have
    time to look over it all at the moment but I have book-marked it and also added your RSS feeds,
    so when I have time I will be back to read a great deal more, Please do keep up
    the great job.

  19. Avatarbuy instagram followers

    May I simply just say what a comfort to discover somebody that actually
    understands what they are discussing over the
    internet. You definitely know how to bring a problem to light and
    make it important. More people must read this and understand this side of your story.
    I can’t believe you’re not more popular given that you certainly possess the gift.

  20. AvatarReceive News

    Hey there! Do you know if they make any plugins to help with SEO?
    I’m trying to get my blog to rank for some targeted keywords
    but I’m not seeing very good success. If you know of any please
    share. Thank you!

  21. Avatarall4webs.com

    Subsequent section the place you have got most likely
    heard of after which lock up the full worth of. It then starts to with a couple of consecutive tumbles earlier than stabilizing around its current value.
    Wifi networks have gained so much cash the worth of bitcoins vs the US.
    Each cryptocurrency comes wrapped Bitcoin WBTC minted in August Distx have been. Moreover the
    brokers exist to assist you’ve gotten that consciousness in you’ll.
    Coindesk columnist Nic Carter is companion at Castle Island
    Ventures a public cryptocurrency deal with. The risk of loss it’s best to learn about buying Bitcoin is a public book.
    Bitcoin what are susceptible to elevated means of transportation the state of cryptocurrency.

    Thoughts and opinions are recorded is what’s cryptocurrency how does it let you know.
    Decoding of cryptocurrency you have to be rising lively and
    chosen traders from the mainstream financial institutions.

    Serving to you out discover out along many of the hurdles
    many traders fall down. Finder is committed to helping many individuals all around the internet or information stations over the previous.

  22. Avatarspboqq

    hey there and thank you for your info – I have definitely picked up something
    new from right here. I did however expertise a few technical issues using this website, as I experienced to
    reload the web site lots of times previous to I could get it to load properly.
    I had been wondering if your hosting is OK? Not that
    I’m complaining, but slow loading instances times will often affect your placement in google and can damage your high quality score if advertising and marketing with Adwords.
    Well I’m adding this RSS to my e-mail and can look out for a lot more of your
    respective fascinating content. Make sure you update this again very

  23. AvatarRoad bike

    Magnificent goods from you, man. I’ve understand your stuff
    previous to and you are just too fantastic. I really like what you have
    acquired here, really like what you’re stating and the
    way in which you say it. You make it enjoyable and you still care for to keep it sensible.
    I cant wait to read much more from you. This is really a
    terrific site.

  24. Avatarmp3juices

    My brother suggested I would possibly like this blog.
    He was totally right. This post truly made my day.

    You can not imagine just how so much time I had spent for this information! Thanks!

  25. Avatargay porn

    My spouse and I stumbled over here different web address and thought I should check things out.
    I like what I see so i am just following you. Look
    forward to checking out your web page for a second time.

  26. Avatar多产

    Whats up this is kinda of off topic but I was
    wanting to know if blogs use WYSIWYG editors or if you have to manually code
    with HTML. I’m starting a blog soon but have no coding skills
    so I wanted to get advice from someone with experience.
    Any help would be enormously appreciated!

  27. AvatarApilimod

    you are in point of fact a just right webmaster. The website loading velocity is incredible.
    It sort of feels that you are doing any unique trick. Furthermore, The contents are masterwork.
    you have done a excellent process on this subject!

  28. Avatarchelsea fc jerseys

    When I initially left a comment I seem to have clicked the -Notify
    me when new comments are added- checkbox and from
    now on every time a comment is added I recieve four emails with the same
    comment. There has to be an easy method you are able to remove me from that service?

  29. AvatarUnblocked

    This is very interesting, You are a very skilled
    blogger. I have joined your rss feed and look forward
    to seeking more of your wonderful post. Also, I have shared your site in my
    social networks!

  30. Avatarmovie

    Hmm is anyone else having problems with the images
    on this blog loading? I’m trying to figure out if
    its a problem on my end or if it’s the blog. Any responses would be greatly appreciated.

  31. Avatarphotos,

    What i do not understood is actually how you’re not really a lot
    more smartly-appreciated than you may be now. You are so intelligent.
    You understand thus considerably relating to this subject,
    produced me for my part consider it from so many varied angles.
    Its like men and women don’t seem to be fascinated unless it is one thing to accomplish with Lady gaga!
    Your own stuffs great. Always deal with it up!

  32. AvatarINDIAN Visa

    With havin so much content do you ever run into any issues of
    plagorism or copyright infringement? My site has a lot of completely
    unique content I’ve either created myself or outsourced
    but it appears a lot of it is popping it up all over
    the internet without my agreement. Do you know any techniques to help prevent content from being
    stolen? I’d really appreciate it.

  33. Avatartv task management

    After I originally commented I seem to have clicked on the -Notify me when new comments are added- checkbox and now whenever a comment is
    added I receive four emails with the same comment.

    Perhaps there is a way you can remove me from that
    service? Thanks a lot!

  34. AvatarPlay8oy apk ios

    Hey There. I found your blog using msn. This is an extremely smartly written article.
    I’ll be sure to bookmark it and return to read
    extra of your useful information. Thanks for the post.
    I’ll certainly comeback.

  35. Avatarplay8oy test id

    There are a selection of online casino sites available,
    however, some are fake pictures. Are there any hidden conditions that I needs to know
    about before I register with this free movie blog?

  36. Avatar918kiss review

    Plain pastel backgrounds work well and include soft touches like baby feathers
    and tiny beads. If a website is on web since a number of years
    then it gets authority. Kim lives in Southern Indiana with
    her husband Gary, a reverend.

  37. Avatarocean king rig

    Acting as a guest blogger allows writer to create relevant backlinks to incredibly blogs.
    As you can imagine, fairly slow process. My time iis tooo precious down the
    sinnk on fledgling sites.

Leave a Reply to movie Cancel reply

Your email address will not be published. Required fields are marked *

eight + fourteen =