1. Home
  2. Docs
  3. BadgeOS Core
  4. Shortcodes And Blocks

Shortcodes And Blocks

Shortcodes and blocks provide you with additional ways to insert BadgeOS content into any page or post. This article will list out the different shortcodes and blocks you can use to insert BadgeOS content on your website pages and explain how to use them.

Table Of Contents

  1. What are shortcodes and blocks?
  2. BadgeOS Shortcodes
  3. How To Use Shortcodes?
  4. BadgeOS Blocks
  5. How To Use Blocks?

1. What are shortcodes and blocks?

Shortcodes

Shortcodes are small snippets of code, contained within brackets that allow you to add dynamic content into the WordPress editor or page builders. Each shortcode has several options called attributes that are used to modify and customize the information displayed.

Blocks

Blocks, like shortcodes, are used to display dynamic content but are generally easier to insert and customize using a visual interface. Blocks can also be inserted into any page or post, however, they require the new Gutenberg content editor. You should keep in mind though that blocks can’t be inserted into a sidebar or used with most page builders. In this case, shortcodes can best help you insert additional content.

2. BadgeOS Shortcodes

You can find all of the BadgeOS shortcodes with a list of their attributes by going to the Help / Support section of the BadgeOS menu from the WordPress dashboard. 

The following are the available shortcodes:

Achievement List[badgeos_achievements_list]

The badgeos_achievements_list  shortcode outputs a list of achievements.

This shortcode has the following attributes:

  • type – Single, or comma-separated list of, achievement type(s) to display. Accepts: all, badges Default: all
  • limit – Number of achievements to display. Default: 10
  • show_filter – Display filter controls. Accepts: True, False Default: true
  • show_search – Display a search input. Accepts: True, False Default: true
  • orderby – Parameter to use for sorting. Accepts: Menu Order, Achievement ID, Achievement Title, Published Date, Last Modified Date, Achievement Author, Random Default: menu_order
  • order – Sort order. Accepts: Ascending, Descending Default: ASC
  • user_id – Show only achievements earned by a specific user.
  • include – Comma-separated list of specific achievement IDs to include.
  • exclude – Comma-separated list of specific achievement IDs to exclude.
  • wpms – Show achievements from all network sites. Accepts: True, False Default: false

Example:
[badgeos_achievements_list limit="10" show_filter="true" show_search="true" orderby="menu_order" order="ASC" wpms="false"]


Single Achievement[badgeos_achievement]

The badgeos_achievement shortcode renders a single achievement.

This  shortcode has the following attributes:

  • id – The ID of the achievement to render.

Example:
[badgeos_achievement id=""]


User Earned Achievements  – [badgeos_user_earned_achievements]

The badgeos_user_earned_achievements shortcode outputs a list of the achievements earned by the user.

This shortcode has the following attributes:

  • type – Single, or comma-separated list of, achievement type(s) to display. Accepts: All, Badges
  • limit – Number of achievements to display. Default: 10
  • show_search – Display a search input. Accepts: True, False Default: true
  • orderby – Parameter to use for sorting. Accepts: Achievement ID, Achievement Title, Award Date, Random Default: ID
  • order – Sort order. Accepts: Ascending, Descending Default: ASC
  • include – Comma-separated list of specific achievement IDs to include. Accepts: Login
  • exclude – Comma-separated list of specific achievement IDs to exclude. Accepts: Login
  • user_id1 – Show only achievements earned by a specific user.
  • wpms – Show achievements from all network sites. Accepts: True, False Default: false
  • show_title – Display Achievement Title. Accepts: True, False Default: true
  • show_thumb – Display Thumbnail Image. Accepts: True, False Default: true
  • show_description – Display Short Description. Accepts: True, False Default: true
  • default_view – Default Listing i.e. List or Grid. Accepts: , List, Grid
  • image_width – Achievement’s image width.
  • image_height – Achievement’s image height.

Example:
[badgeos_user_earned_achievements type="" limit="10" show_search="true" orderby="ID" order="ASC" include="" exclude="" user_id1="" wpms="false" show_title="true" show_thumb="true" show_description="true" default_view="" image_width="" image_height=""]

User Earned Ranks  – [badgeos_user_earned_ranks]

The badgeos_user_earned_ranks shortcode outputs a list of the ranks earned by the user.

This shortcode has the following attributes:

  • rank_type – Single, or comma-separated list of, Rank type(s) to display. Accepts: Level
  • limit – Number of Ranks to display. Default: 10
  • show_search – Display a search input. Accepts: True, False Default: true
  • orderby – Parameter to use for sorting. Accepts: Rank ID, Rank Title, Award Date, Random Default: rank_id
  • order – Sort order. Accepts: Ascending, Descending Default: ASC
  • user_id1 – Show only ranks earned by a specific user.
  • default_view – Default Listing i.e. List or Grid. Accepts: , List, Grid
  • show_title – Display Rank Title. Accepts: True, False Default: true
  • show_thumb – Display Thumbnail Image. Accepts: True, False Default: true
  • show_description – Display Short Description. Accepts: True, False Default: true
  • image_width – Achievement’s image width.
  • image_height – Achievement’s image height.

Example:
[badgeos_user_earned_ranks rank_type="" limit="10" show_search="true" orderby="rank_id" order="ASC" user_id1="" default_view="" show_title="true" show_thumb="true" show_description="true" image_width="" image_height=""]

User Earned Points  – [badgeos_user_earned_points]

The badgeos_user_earned_points shortcode outputs a list of the points earned by the user.

This shortcode has the following attributes:

  • point_type – Single point type to display.
  • user_id1 – Show only points earned by a specific user.
  • show_title – Display Point Title. Accepts: True, False Default: true

Example:
[badgeos_user_earned_points point_type="" user_id1="" show_title="true"]

Single Rank – [badgeos_rank]

The badgeos_rank shortcode renders a single rank.

This shortcode has the following attributes:

  • id – The ID of the rank to render. Accepts: Intermediate, Beginner
  • show_title – Display Rank Title. Accepts: True, False Default: true
  • show_thumb – Display Thumbnail Image. Accepts: True, False Default: true
  • show_description – Display Short Description. Accepts: True, False Default: true
  • image_width – Rank’s image width.
  • image_height – Rank’s image height.

Example: [badgeos_rank id="" show_title="true" show_thumb="true" show_description="true" image_width="" image_height=""]

Rank List[badgeos_ranks_list]

The badgeos_ranks_list shortcode outputs a list of Ranks.

This shortcode has the following attributes:

  • types – Single, or comma-separated list of, Rank type(s) to display. Accepts: Level
  • limit – Number of Ranks to display. Default: 10
  • show_search – Display a search input. Accepts: True, False Default: true
  • orderby – Parameter to use for sorting. Accepts: Rank ID, Rank Title, Award Date, Random Default: rank_id
  • order – Sort order. Accepts: Ascending, Descending Default: ASC
  • default_view – Default Listing i.e. List or Grid. Accepts: , List, Grid
  • user_id1 – Show only ranks earned by a specific user.
  • show_title – Display Rank Title. Accepts: True, False Default: true
  • show_thumb – Display Thumbnail Image. Accepts: True, False Default: true
  • show_description – Display Short Description. Accepts: True, False Default: true
  • image_width – Achievement’s image width.
  • image_height – Achievement’s image height.

Example: [badgeos_ranks_list types="" limit="10" show_search="true" orderby="rank_id" order="ASC" default_view="" user_id1="" show_title="true" show_thumb="true" show_description="true" image_width="" image_height=""]

Achievement Evidence[badgeos_evidence]

The badgeos_evidence shortcode renders a single achievement’s evidence page.

This shortcode has the following attributes:

  • achievement – Achievement ID to show. Accepts: Login
  • user_id1 – Achievement Earned by.
  • award_id1 – Achievement awarded record.

Example: [badgeos_evidence achievement="" user_id1="" award_id1=""]

Nomination Form[badgeos_nomination]

The badgeos_nomination shortcode renders a nomination form for a specific achievement.

This shortcode has the following attributes:

  • achievement_id – Achievement ID to award.

Example: [badgeos_nomination achievement_id=""]


Nominations List – [badgeos_nominations]

The badgeos_nominations shortcode displays a filterable list of nominations.

This shortcode has the following attributes:

  • limit – Number of nominations to display. Default: 10
  • status – Nomination statuses to display. Accepts: All, Approved, Denied, Pending Default: all
  • show_filter – Display filter controls. Accepts: True, False Default: true
  • show_search – Display a search input. Accepts: True, False Default: true

Example: [badgeos_nominations limit="10" status="all" show_filter="true" show_search="true"]


Submission Form – [badgeos_submission]

The badgeos_submission shortcode renders a submission form.

This shortcode has the following attributes:

  • achievement_id – Achievement ID to award.

Example: [badgeos_submission achievement_id=""]


Submissions List – [badgeos_submissions]

The badgeos_submissions displays a filterable list of submissions

This shortcode has the following attributes:

  • limit – Number of submissions to display. Default: 10
  • status – Display only submissions of this status. Accepts: All, Approved, Denied, Pending Default: all
  • show_filter – Display filter controls. Accepts: True, False Default: true
  • show_search – Display a search input. Accepts: True, False Default: true
  • show_attachments – Display submission attachments. Accepts: True, False Default: true
  • show_comments – Display submission comments. Accepts: True, False Default: true

Example: [badgeos_submissions limit="10" status="all" show_filter="true" show_search="true" show_attachments="true" show_comments="true"]

3. How To Use Shortcodes?

All shortcodes use square brackets “[ x ]” around the name of the particular shortcode being used. Shortcode attributes are listed within the brackets after the shortcode name.  They can be inserted into any area of a page or post. You can also add the BadgeOS shortcodes into the pages and posts by clicking on the Add BadgeOS Shortcode button on the editor.

4. BadgeOS Blocks

These are the available BadgeOS blocks:

  • Single Achievement Block displays a single achievement on a page or post.
  • The Achievement List Block displays a list of all achievements.
  • The User Earned Achievements Block displays a list of all the achievements the user viewing the page/post has earned. All listed earned achievements link to another page. If the achievement is an open badge, the link redirects the user to the evidence page. If the achievement is a normal badge the link redirects the user to the badge’s detail page.
  • The User Points Achievements Block displays a list/grid of all the points earned by the user visiting the page/post. 
  • The User Ranks Achievements Block displays a list/grid of all the ranks earned by the user viewing the page/posy.
  • The Single Rank Block displays a single rank.
  • The Ranks List Block displays a list of all ranks.
  • The Evidence Block displays the evidence page for the user’s badges.

5. How To Use Blocks?

Using the Gutenberg block editor, you can use BadgeOS blocks at any post, page, and other custom post types.

To do so, please follow these steps:

  • Navigate to the desired post/page.
  • Click at the “Add Block” icon (+).
  • Scroll down to the “BadgeOS Block” or search “BadgeOS.”
  • Expand the section.
  • Select the required block.
  • Set up the block from the right sidebar.
  • Publish/Update.

The user can view the displayed earned points, achievements, or ranks in both list and grid view.