Shortcodes in Ahimsa for WordPress
May 31st, 2010 by ravi

For a couple of releases now, the Ahimsa theme for WordPress has included two shortcodes which I have been too lazy to document, and this post attempts to rectify that.

Quick Fancybox Gallery

If you are not happy with just simple old Lightbox for displaying images (and image galleries), then the Fancybox is what you need, and happily for you, and using Fancybox in your blog is trivial with the Ahimsa theme using the qfgallery shortcode.

Here’s what it’s supposed to do:

QFGallery Shortcode Demo

And here’s how:

    [qfgallery title=”Photographs from Spain” scale=”0″ orient=”landscape” float=”left|right”]
    URL to image 1|title1
    URL to image 2|title2
    URL to image 3|title2
    [/qfgallery]

As is perhaps obvious, what the above does is create a thumbnail gallery (the thumbnails are sized at 128×128 pixels) of the three images, and attaches the Fancybox trigger to them, so that when a thumbnail is clicked the original picture pops up in a Fancybox window (which also provides navigation).

All arguments to the shortcode are optional.

The argument scale specifies if the image should be scaled down for the thumbnail or just a 128×128 part of it should be displayed in the thumbnail (the latter is the default). This is a good time to mention that thumbnails are generated in a hacky way: they are not created at all, but are merely browser scaled down versions of the original image. I admit this is a bad idea, especially if you have lots of images, and my only defence (if it can be called that) is that I created this shortcode to make it easy for me to post a few images without having to worry about scaling them to thumbnails, or having to use WordPress’s media manager, etc.

The orient argument specifies if the thumbnails should be displayed left to right and then in additional rows if necessary (“landscape” mode, which is the default) or in a thin vertical strip with one thumbnail per row (“portrait” mode).

The float argument translates to an equivalent setting for the CSS float property. If you want the thumbnail box to be to the right of the content, use the value “right”. Etc.

You can specify a name or title for each image by adding a “|” (pipe) symbol after the URL and then the text for the title.

FAQinWay

FAQinWay is a trivial implementation of a FAQ (a list of answers to Frequently Asked Questions) in a page or post. The answers to each question is revealed below when the reader clicks on the question. For an example, see the Ahimsa FAQ page. Questions and answers are added using the FAQinWay shortcode thus:


    [faqinway]
    This is the first question
    @@@
    This is an answer to the first question
    $$$
    This is a second question
    @@@
    Answer to the second question
    [/faqinway]
6 Responses  
  • Mojtaba Cazi writes:

    Hi Ravi,
    The QFgallery not works for me :(
    when i click on an image it open in a new borwser tab

    • ravi writes:

      Mojtaba, can you point me to a page where this happens? You can email me (code [at] ahren [dot] org) if you wish. This is usually a sign of a JavaScript error which might be an issue in my code, but potentially also in some other plugin code.

  • Mojtaba Cazi writes:

    Another think that i want to know is, is there any shortcode for encapsulating a word in post? or you done it by html codes inside posts? (eg you encapsulate these words in current post: “shortcodes”, “Lightbox”, …)

    • ravi writes:

      Mojtaba, I was experimenting with things a bit, so you cannot exactly reproduce what I did, but there is a way to do this provided you don’t care about the colour, and you are not worried about the word wrapping etc. In such a case, you can wrap the text in a some-text tag.

  • Zachary Williams writes:

    Hello Ravi. Thank you for a fast reply to my questions about the gallery. I just wanted to say that I hadn’t intended to point out some mistake you made about the Help & Support Link. Quite the opposite; my point was that web development is tough and anyone who even gets it half right deserves respect. I really like your work and am glad you make it available for use and study. All the best, Zach.

    • ravi writes:

      Hello Zach, no worries. I wasn’t offended at all. The broken Help/Support thing really bugs me – it’s an eyesore – and this is not the first time Tender App has broken my setup through what I believe are poorly considered code changes.


Leave a Reply

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

If you need help with one of my software projects, please click: Using that link, you might even find a previous report of (and solution for) the issue!
SIDEBAR
»
S
I
D
E
B
A
R
«
»  Substance: WordPress  »  Style: Ahren Ahimsa