How To

Suffusion comes armed with a good set of very useful short codes. In this post I wanted to highlight the short codes you get and I also wanted to provide an insight into how you can use short codes in general.

What is a Short Code?

A short code is a macro code introduced in WordPress 2.5. When inserted into regular content, the short code executes a piece of associated PHP code that prints out specific output. The most common example of short codes is the “gallery” short code provided by WordPress out of the box.

The following is the list of short codes provided within Suffusion:

  1. Short code: [suffusion-categories]
    Brief Description: Used to print a list of categories.
    Parameters and Usage: This takes most if not all parameters of the WP call for wp_list_categories().
    Use Case: If you want to display the list of categories from within a post. Since you can use most options of wp_list_categories, this is as powerful as running a query in the back-end.
  2. Short code: [suffusion-the-year]
    Brief Description: Prints the current year.
    Parameters and Usage: This doesn’t take any parameters. Simply invoking [suffusion-the-year] prints the current year. This is generated by the short code: 2012.
    Use Case: If you want the current year to be shown in the copyright.
  3. Short code: [suffusion-site-link]
    Brief Description: Prints the link to your site.
    Parameters and Usage: This doesn’t take any parameters. Simply invoking [suffusion-site-link] prints the title of your site and links it to your site. This is generated by the short code: Aquoid Themes.
    Use Case: If you want to print the title of your site with a URL linking to it.
  4. Short code: [suffusion-the-author]
    Brief Description: Used to print information about the author of a post.
    Parameters and Usage: This takes one parameter, display. Depending on the value of display certain information is printed about the author of a post. The display parameter could have any of the following values:
    • author – Displays the display name of the author of the post
    • modified-author – Displays the display name of the author who modified the post
    • description – Displays the biographical information set in the author’s profile
    • login – Displays the login name of the author of the post
    • first-name – Displays the first name of the author of the post
    • last-name – Displays the last name of the author of the post
    • nickname – Displays the nickname of the author of the post
    • id – Displays the id of the author of the post
    • url – Displays the URL of the author of the post. This is only the URL, hence it needs to be suitably combined with the name of the author for a meaningful display
    • email – Displays the email of the author of the post
    • link – Displays the name of the author of the post, linking to the author’s URL
    • aim – Displays the AIM details of the author of the post. For this to work the AIM account details should be set in the user profile section of the author.
    • yim – Displays the Yahoo details of the author of the post. For this to work the Yahoo account details should be set in the user profile section of the author.
    • posts – Displays the number of posts written by the author of the post.
    • posts-url – Displays the URL for all posts by the author. Since this is only a URL, it might need to be combined with some more meaningful text for a better display.
    • twitter – Displays the link to the Twitter URL of the author of the post. Requires you to set up Twitter as a user contact method from Blog Features → User Profiles
    • facebook – Displays the link to the Facebook URL of the author of the post. Requires you to set up Facebook as a user contact method from Blog Features → User Profiles
    • technorati – Displays the link to the Technorati URL of the author of the post. Requires you to set up Technorati as a user contact method from Blog Features → User Profiles
    • linkedin – Displays the link to the LinkedIn URL of the author of the post. Requires you to set up LinkedIn as a user contact method from Blog Features → User Profiles
    • flickr – Displays the link to the Flickr URL of the author of the post. Requires you to set up Flickr as a user contact method from Blog Features → User Profiles
    • delicious – Displays the link to the Del.icio.us URL of the author of the post. Requires you to set up Del.icio.us as a user contact method from Blog Features → User Profiles
    • digg – Displays the link to the Digg URL of the author of the post. Requires you to set up Digg as a user contact method from Blog Features → User Profiles
    • stumbleupon – Displays the link to the StumbleUpon URL of the author of the post. Requires you to set up StumbleUpon as a user contact method from Blog Features → User Profiles
    • reddit – Displays the link to the Reddit URL of the author of the post. Requires you to set up Reddit as a user contact method from Blog Features → User Profiles

    The following invocation of the short code:

    [suffusion-the-author display='author'] has written <a href='[suffusion-the-author display='posts-url']'> [suffusion-the-author display='posts'] posts</a>.
    He can be followed on <a href='[suffusion-the-author display='twitter']'>Twitter</a>.

    produces:

    Sayontan has written 166 posts. He can be followed on Twitter.

    Use Case: If you want to insert author-specific information at the bottom of a post, like the number of articles, a brief description etc.

  5. Short code: [suffusion-the-post]
    Brief Description: Used to print information about a post, like the id, title and permalink.
    Parameters and Usage: This takes one parameter, display. Depending on the value of display a certain piece of information is displayed. The following invocation:
    This post has an id [suffusion-the-post display='id']. Its permalink is [suffusion-the-post display='permalink'] and the title is [suffusion-the-post display='title'].

    produces:

    This post has an id 808. Its permalink is http://aquoid.com/news/2010/09/wordpress-short-codes-in-suffusion/ and the title is WordPress Short Codes in Suffusion.

    Use Case: If you want to insert post-specific information at the bottom of a post.

  6. Short code: [suffusion-login-url]
    Brief Description: Prints the login URL for the site.
    Parameters and Usage: This takes no parameters.
    Use Case: If you don’t want the Meta widget, but want to show a login URL
  7. Short code: [suffusion-logout-url]
    Brief Description: Prints the logout URL for the site.
    Parameters and Usage: This takes no parameters.
    Use Case: If you don’t want the Meta widget, but want to show a logout URL
  8. Short code: [suffusion-loginout]
    Brief Description: Prints the URL to login if logged out or logout if logged in.
    Parameters and Usage: This takes no parameters.
    Use Case: If you don’t want the Meta widget, but want to show a URL to logout if a user is logged in and vice versa.
  9. Short code: [suffusion-register]
    Brief Description: Prints the URL to register as a member of the site.
    Parameters and Usage: This takes no parameters.
    Use Case: If you don’t want the Meta widget, but want to show a registration URL
  10. Short code: [suffusion-adsense]
    Brief Description: Prints AdSense code based on specified parameters.
    Parameters and Usage: This takes four parameters: client, slot, width and height. It inserts the corresponding ad when invoked. I don’t have an AdSense account, so I cannot demonstrate this, though.
    Use Case: If you want to insert an advertisement in the body of a post.
  11. Short code: [suffusion-tag-cloud]
    Brief Description: Prints a tag cloud.
    Parameters and Usage: This takes three parameters: smallest, largest and number, respectively indicating the smallest font size (default 8), the largest font size (default 22) and the number of tags to display (default 45).
    Use Case: If you are not satisfied with the default “Tag Cloud” widget and would like more control over how many tags to display and in what sizes. You could use this in a text widget too, to simulate the tag-cloud widget.
  12. Short code: [suffusion-widgets]
    Brief Description: Prints an ad hoc widget area, based on specified parameters.
    Parameters and Usage: To use this short code you first have to go to Appearance → Widgets, then fill in the widgets you want in the widget areas titled Ad Hoc Widgets 1, Ad Hoc Widgets 2, … Ad Hoc Widgets 5. You don’t need to put widgets in all of them – just put them in the ones you want to use. The short code takes 3 parameters – id, container and container-class. You could invoke the short code thus:
    [suffusion-widgets id='2' container-class='custom-class']

    This prints the widget area for Ad Hoc Widgets 2 and assigns the widget area a class called ‘custom-class’. If you pass the container parameter with a value 'false' then the widgets are not put in any container (and the container-class parameter is ignored).
    Use Case: If you want to display some widgets from within a post.

  13. Short code: [suffusion-multic] and [suffusion-column]
    Brief Description: This was introduced in version 3.6.0 to support multi-column layouts. These short codes are dependent on each other.
    Parameters and Usage: The [[suffusion-multic] short code takes no parameters and is used as a container indicating that you have a multi-column layout within. The [suffusion-column] short code takes the parameter width, which could have values 1, 1/2, 1/3, 1/4, 2/3, 3/4, 100, 050, 033, 025, 066 and 075, indicating what fraction of the width is to be taken up by a column. The default is 1. This is how you can use the short code:
    [[suffusion-multic]
      [suffusion-column width='1/2']A column with 1/2 the total width [/suffusion-column]
      [suffusion-column width='1/4']A column with 1/4 the total width[/suffusion-column]
      [suffusion-column width='1/4']Another column with 1/4 the total width[/suffusion-column]
    [/suffusion-multic]

    This is how the above looks:

    A column with 1/2 the total width
    A column with 1/4 the total width
    Another column with 1/4 the total width

    Mind you, WP has a nasty habit of inserting <p> tags at line breaks, so you might have to be careful about stripping out new lines from the above code before using it.

This list will be expanded as more short codes are added to Suffusion. As usual, please don’t post support queries here. Use the Support forum instead.

 

After a lot of delays and innumerable back-and-forth exchanges, a version of Suffusion has finally been approved – 3.6.3. This is essentially a combination of a large number of features and fixes, from release 3.5.8 through 3.6.3. If you look at the Change Log.txt file in the theme folder you will get an idea about how big the changes actually are:

  1. Bug Fixes
    There were quite a few bug fixes, actually:
    1. Fixed a bug that was displaying the “Comment form closed” message even if the settings were done to hide them. The slow approvals mean that questions get asked hundreds of times on the forum – this happened to be the top question over the last month.
    2. Fixed a minor problem with the style resets that I introduced in 3.5.6. This particular bug was causing Gallery items to spill over into a new line.
    3. The “Page of Posts” template was showing a NOTICE message with WordPress debugging turned on. I have fixed this.
    4. In my zeal to optimize code I had removed a bit too much in the “Now Reading” library page. The page was throwing up an error – that has now been fixed.
    5. Fixed a bug in the suffusion-tag-cloud short code. This was assigning an incorrect value to the number parameter.
      Note: You can use this short code in a text widget to display a tag cloud. It gives you a lot more control in terms of the number of tags you want to show and the sizes you want to set for each.
    6. Fixed a bug in the Custom Post Types section that was not saving post types with the correct index.
    7. Fixed a bug that was causing single quote characters in the post title to cause invalid markup.
    8. Fixed a bug in the “No Sidebars” template where the maximum width of the image was being set incorrectly.
    9. An incorrect control switch was being used to determine if custom font settings were to be used. This has been fixed.
      Note: If your fonts suddenly seem to have changed, go to Visual Effects → Body Font Settings and select “Custom Styles” for the first option and save.
    10. Fixed a couple of XHTML validation bugs. The first would occur if you have a gradient image selected for the header, and the second would occur if you had opted to use compression (GZip or minification) on the CSS files.
  2. New Features
    There were tons of new features added.
    1. New Widget Areas
      There are nine new widget areas. Technically there are five, but the fifth is a special kind:
      1. Widgets Above Header – This is in response to requests to be able to display ads above the header.
      2. Header Widgets – This, again, is in response to requests to be able to use the blank space near the blog header.
      3. Wide Sidebar (Top) – This is widget area that sits above both your sidebars if your sidebars are on the same side. Otherwise this is not shown. It is as wide as both your sidebars combined.
      4. Wide Sidebar (Bottom) – This is widget area that sits below both your sidebars if your sidebars are on the same side. Otherwise this is not shown. It is as wide as both your sidebars combined.
      5. Ad Hoc Widgets 1 to 5 – This is something new and quite interesting. There are 5 new widget areas called Ad Hoc Widgets 1, … Ad Hoc Widgets 5. You can add any widgets you please there. You can then invoke these widget areas from within your posts or pages, if you want. You have short codes to do this:
        [suffusion-widgets id='3']

        You can use any number from 1 to 5 for the id.

    2. As stated above, the short code to display ad hoc widgets, suffusion-widgets is new.
    3. There is a new page template for logging in, called “Log In”. You can use this template to create a login page for users. Mind you, this doesn’t tie up with the Meta Widget directly. You have to explicitly provide the link to users to log in.
    4. You can now customize the labels on your Comment form. Head over to Blog Features → Comment Settings to do so.
    5. There is a new Polish translation, thanks to Robert Maculewicz!
    6. JavaScript files are now added to the bottom of the page by default. You can change this by going to Blog Features → Site Optimization.
    7. Added capability to display text in multiple columns using short codes [suffusion-multic] and [suffusion-column]
    8. Added translation support for child themes.
    9. Added support for assigning menus to locations in the Appearance → Menus section of the admin panel. This comes with a change of behavior: if you assign a menu to the Top Navigation Bar and the Top Navigation Bar is hidden, it will still show up. Additionally if a menu is not assigned to a navigation bar in the Navigation Bar Setup options, but is assigned through the Menu administration page, the menu will show up.
  3. Modifications
    Some of the existing functionality has changed:
    1. Code Optimization
      This is yet another release where I have reworked the back-end. The impact this time, though, is not severe. I had noticed, as had quite a few users that the options panel had become quite sluggish. Of course, when you are looking at 400+ options loaded from a 6000 line file into JavaScript memory you are bound to have performance impacts. So I did a subtle split of the options menu and prevented it all from adding to the JS footprint. Earlier you had this:
      Previous Look

      Previous Look


      You now have this:
      New Look

      New Look


      I have essentially moved all the horizontal tabs into the side menu. The back-end is now noticeably quicker than what it was in the previous releases.
    2. I made minor CSS changes to the Minima skin. I will continue to tweak the style sheet in minor ways till I am convinced it looks good.
    3. I have switched off the “Comment form closed” message by default. Users who wanted to see the message will need to revisit the settings in Blog Features → Comment Settings.
    4. Code Housekeeping:
      1. Replaced occurrences of include(TEMPLATEPATH . '/searchform.php') with get_search_form(). This is as per the new approval process and it improves child theme support.
      2. Replaced occurrences of file includes with get_template_part(). This is as per the new approval process and it improves child theme support w.e.f. WP 3.0.
      3. Removed support for comments from WP versions older than 2.7. Suffusion anyway has been relying on at least 2.8 for widgets since a long time, so this code was redundant.
      4. Added call to new function comment_form() in comments.php. This is as per the new approval process, though it is quite counter-intuitive. I had to leave the old code in place, because there are still users who use WP 2.9 and for them the new function will not work.
      5. Moved licensing information to style.css file. This doesn’t impact you as an end-user.
      6. Enqueued all JavaScript file inclusions.
    5. Updated Brazilian Portuguese translation, thanks to Alcides Soares!
    6. Changed behavior to exclude posts from the static Featured Content section in the rest of the content on a page.

Hope you like this combined multi-release.

 

It was quite a surprise to see WordPress approve version 3.1.9 before 8:30 AM on the Pacific Coast. Nonetheless, here are the highlights of this release:

  1. “Update Available” notification:

    I am happy to announce that I have put in support for a long-requested feature: an “Update Available” notification!! Mind you, if you have problems with automatic upgrades in general, this feature might not work. However, in general it should. After you install version 3.1.9, whenever you have a new version you should see something like this:

    suf-update-available-1
  2. User Profile Enhancement:
    There were some nifty enhancements in WordPress 2.9. This release takes advantage of one such feature – custom contact methods. Under “Blog Features” you will now see a section called “User Profiles”. You can then choose to include things like your Facebook and Twitter information in the Users –> Your Profile section.
  3. Author short codes
    A nice addition in this release is a set of very useful short codes. The short code is called “suffusion-the-author”. You can invoke it in your posts / pages by writing this:
    [suffusion-the-author display=’what-to-display’]

    The complete list of arguments that you can pass to the ‘display’ parameter is as follows:

    1. author – Shows the author name as defined in the “Display name publicly as” setting for the user
    2. modified-author – Shows the author who last modified the post
    3. description – Shows the author description, as filled in the profile page
    4. login – Shows the login id of the author
    5. first-name – First name of the author, as filled in the profile page
    6. last-name – Last name of the author, as filled in the profile page
    7. nickname – Nickname of the author, as filled in the profile page
    8. id – Id of the author
    9. url – Website of the author, as filled in the profile page
    10. email – Email of the author, as filled in the profile page
    11. link – Shows the website of the author if available, otherwise shows the display name
    12. aim – The link to the AIM profile
    13. yim – The link to the Yahoo IM profile
    14. posts – Number of posts by the author
    15. posts-url – A link to the author page for the author
    16. twitter – The link to the Twitter page, available only if Twitter is included in the user profile.
    17. facebook – The link to the Facebook page, available only if Facebook is included in the user profile.
    18. technorati – The link to the Technorati page, available only if Technorati is included in the user profile.
    19. linkedin – The link to the LinkedIn page, available only if LinkedIn is included in the user profile.
    20. flickr – The link to the Flickr page, available only if Flickr is included in the user profile.
    21. delicious – The link to the Delicious page, available only if Delicious is included in the user profile.
    22. digg – The link to the Digg page, available only if Digg is included in the user profile.
    23. stumbleupon – The link to the StumbleUpon page, available only if StumbleUpon is included in the user profile.
    24. reddit – The link to the Reddit page, available only if Reddit is included in the user profile.
  4. “About the Author”

    You can now display an “About the Author” section for posts and pages. Fill in the contents in the “Author Information Content” section of the “User Profiles” section. You can mix and match the author short codes in this option:

    [suffusion-the-author display=’description’]
    [suffusion-the-author] has written <a href=”[suffusion-the-author display=’posts-url’]”>[suffusion-the-author display=’posts’] posts</a>. 

    This will generate put in the author description and add a line indicating how many posts the author has written.

I would like to take a moment and thank Connie Müller-Gödecke and Scott Beardsley for the incredible help you have been on the support forum. You have both considerably eased my workload!

© 2011 Aquoid Themes Suffusion theme by Sayontan Sinha