WordPress Questions and Answers (CMA) - Shortcodes - Shortcode List and Explanation


Using Shortcodes

Back to User Guides

TIP: What Are Shortcodes

Shortcodes add dynamic content to your site via a small piece of code.

Learn more: Shortcodes - How To Use | Finding ID of Post/Page/Other Content

The WordPress Questions and Answers lets you insert dynamic content on your WordPress website posts or pages by using the plugin's shortcodes. Note that they are always written between brackets [ ] and are case-sensitive.

The up-to-date list of all shortcode can be found in the plugin admin menu. 

Navigation to the shortcodes list - Discussion Forum Plugin for WordPress
Navigation to the shortcodes list

Video Guide


Supported Shortcodes in Detail

[cma-questions]

General vs. Specific Settings

The shortcode settings in this guide will be applied to a specific Table of Questions.

You can set the default Table of Question from the settings. Learn more: Customizing Table of Questions (Number of Answers, View Count etc)

Use: Shows the questions table.

Filtering parameters:
  • author - ID of the question author (default: empty) [Question only]
  • limit - number of questions per page to display, default is 5
  • contributor - ID of the question author or user who has answered for the question (default: empty) [Question only]
  • cat - a slug of a category (multiple categories should be separated by commas) (default: empty)
  • answered - show only unanswered (0) or only answered (1) questions. Default: empty (all questions).
  • resolved - show only unresolved (0) or only resolved (1) questions. Default: empty (all questions).
  • subtree - limit the categories filter options only to subcategories of the current category given by the cat parameter (default: 0)
  • tag - a slug of a tag (multiple tag should be separated by commas) (default: empty). Don't confuse with the tags attribute
View parameters:
  • ajax - enable or disable AJAX support (default: 1)
  • sort - one of the following: newest, hottest, views, votes (default: newest)
  • form - add "question form" (default: 0)
  • formontop - display the question form above the questions table (default: 0)
  • dateposted - display the thread posted date (default: 0)
  • showcontent - display the question's content below the title when showcontent=1 or fragment when showcontent=fragment (default: 0)
  • search - add "search form" above list (default: 1)
  • pagination - show pagination (default: 1)
  • hidequestions - hides the question list (default: 0)
  • votes - show the number of votes (default: 1)
  • views - show the number of views (default: 1)
  • answers - show the number of answers (default: 1)
  • updated - show the information about question's last update (default: 1)
  • authorinfo - show the information about the question's author (default: 1)
  • statusinfo - show the information about the question's status (default: 0)
  • tags - show questions' tags (default: 1). Don't confuse with the tag attribute
  • navbar - show the full navigation bar (default: 0)
  • sortbar - show the sorting bar (default: 0)
  • scrollaftersearch - scroll to the top of the container after loaded new subpage (default: 1)
  • categorybeforetitle - show category before question title (default: 0)
  • showanswer - show the recent answer under the question title (default: 0)
  • metaposition - display views, votes and answers box on the left side (0) or on the right side (1) (default: 0)
Example

[cma-questions limit="10" author="123" sort="hottest" form="1"]

Example

The forum category shortcode  [cma-questions cat="tooltipglossary" form="1" navbar="0" views="0" votes="0" updated="0" answers="0"]  will result in:

Displaying a forum using the shortcode - WordPress Question and Answer Plugin
Displaying a forum using the shortcode

[cma-index]

Use: Shows the questions table. Works the same as the [cma-questions] but has different default values that come from the Index page settings.

Displaying the index page using the shortcode - WordPress Forum Plugin
Displaying the index page using the shortcode

[cma-my-questions]

Use: Shows current user's questions, in the same way, it's displayed on the contributor's page. It supports the same parameters as the [cma-questions] shortcode.

Displaying the questions using the shortcode - WordPress Discussion Forum
Displaying the questions using the shortcode

[cma-favorite-questions]

Use: Shows only the questions favorited by the current user. Effectively, the same as [cma-questions favorite="1"]

Displaying favorite questions using the shortcode - WordPress Q and A Plugin
Displaying favorite questions using the shortcode

[cma-answers]

Use: Shows the answers table

Filtering parameters:
  • author - ID of the answer author, it's required. If no author is specified, the shortcode will not return anything
  • limit - number of results per page to display, default is 5
View parameters:
  • ajax - enable or disable AJAX support (default: 1)
[cma-answers author="1"]
Displaying answers using the shortcode - Discussion Forum Plugin for WordPress
Displaying answers using the shortcode

[cma-my-answers]

Use: Shows current user's answers in the same way it's displayed on the contributor's page.

Supported parameters:
  • ajax - Enable AJAX support so clicking on the question won't reload the current page.
  • limit - Set the amount of answers that can be displayed on the page. Note: this parameter was introduced in version 4.5.5.

Example 1:

[cma-my-answers ajax]

Displaying user's answers using the shortcode - WordPress Question and Answer Plugin
Displaying user's answers using the shortcode

Example 2:

[cma-my-answers limit="3"]

Displaying user's answers with the limit using the shortcode - WordPress Forum Plugin
Displaying user's answers with the limit using the shortcode

[cma-categories]

Use: Shows the categories table.

Parameters

  • questions - shows the number of questions
  • unanswered - shows unanswered questions number
  • answers - shows the number of answers
  • follow - adds the Follow/Unfollow button for each category
  • header - shows table header
  • parent - shows only subcategories of given parent category (slug or ID)
Sample
Displaying the table with forum categories using the shortcode - WordPress Discussion Forum
Displaying the table with forum categories using the shortcode
Example

[cma-categories questions=1 answers=1 follow=1 header=1 unanswered=1 parent=category experts=0]

Displaying the table with forum categories using the shortcode with additional parameters - WordPress Q and A Plugin
Displaying the table with forum categories using the shortcode with additional parameters

[cma-categories-list]

Use: Shows the categories list

Parameters

  • view - write "accordion" to show the accordion view. 
Example

[cma-categories-list]

Displaying the list with categories using the shortcode - Discussion Forum Plugin for WordPress
Displaying the list with categories using the shortcode

[cma-categories-list view="accordion"]

Displaying the list with categories using the shortcode and 'accordion' view - WordPress Questions and Answers
Displaying the list with categories using the shortcode and 'accordion' view

[cma-followed]

Use: Shows current user's followed threads and categories.

Parameter

  • author - Displays followed questions posted by a certain author only. The parameter accepts the author's ID as a value. By default, the value is "empty". Note: this paramater was introduced in version 4.7.0.

All followed threads: 

[cma-followed]

Displaying the list of user's subscriptions - WordPress Question and Answer Plugin
Displaying the list of user's subscriptions

Followed threads posted by a certain author (which user ID is "3", for example): 

[cma-followed author="3"]

Displaying the list of user's subscriptions by a certain author - WordPress Forum Plugin
Displaying the list of user's subscriptions by a certain author

[cma-question-form]

Use: Shows the question form

Parameters:
  • cat - (optional) category's slug or term ID that the question will be posted to.
  • title - show title or not. Values: 0 or 1, default is 0.
  • backlink - show the backlink or not. Values: 0 or 1, default is 1.
  • loginform - show the login form for logged out users. Values: 0 or 1, default is 0.
  • expert - (optional) set pre-defined expert's ID that the question will be assigned to. Note: this parameter was introduced in version 4.6.4 and is related to the Answers Experts Add-on version 2.1.1 or higher. Learn more about this parameter in this guide: Answers Experts (CMA) - Shortcodes
Displaying the form for asking a question on the forum using a shortcode - WordPress Discussion Forum
Displaying the form for asking a question on the forum using a shortcode

[cma-board]

Use: Shows questions divided by categories.

Parameters:
  • showquestions - whether to show the questions. Values are 0 or 1, default is 1.
  • questionslimit - limit number of questions.
Displaying questions divided by categories - WordPress Q and A Plugin
Displaying questions divided by categories

[cma-get-param-author]

Use: Returns "author" parameter from URL. E.g. if the URL is/custom-user-page/?author=123, the shortcode will return 123

May be used combined with the  [cma-questions] or [cma-answers] shortcodes in order to create a custom contributor's page.

Examples

[cma-questions author="[cma-get-param-author]"]

[cma-answers author="[cma-get-param-author]"]

Questions list example - Discussion Forum Plugin for WordPress
Questions list example

[cma-delete]

Use: Displays a link that allows the user to delete all questions and answers.

Note: This feature is relevant to GDPR compliance. Learn more: User Data Privacy and GDPR Compliance


[cma-questions-count] 

Use: Returns the number of question of one or more categories.

Parameters

  • cat (optional) -  count number of answers from this category. Supports ID and slug.

    Use multiple IDs to show sum of answers of many categories. If "cat" is not specified, the shortcode will count the questions in all categories.

Examples

[cma-questions-count]

[cma-questions-count cat="1"]

The categories cat1 and cat2 have [cma-questions-count cat="cat1,cat2"] questions in total

Displaying the amount of questions in one or multiple categories - WordPress Questions and Answers
Displaying the amount of questions in one or multiple categories

[cma-question-expert-info]

Use: Returns the expert info. Optionally, it includes an avatar screenshot and name.

Parameters

  • avatar - Include avatar screenshot (1) or don't include (0). Default is 0
  • name - Include avatar (1) or don't include (0). Default is 1

Example

[cma-question-expert-info avatar="1" name="1"]


Attaching YouTube and Vimeo clips

To attach a YouTube or Vimeo clip to the thread, just put the URL in brackets. 

Example 

[https://youtu.be/Zkdf3kaso]


More information about the WordPress Questions and Answers plugin

Other WordPress products can be found at CreativeMinds WordPress Store

Let us know how we can Improve this Product Documentation Page

To open a Support Ticket visit our support center
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.