Summary of shortcodes

Discussion Board has the following shortcodes:

[discussion_board_form] – displays your new topic form to permitted users

[discussion_topics] – displays a list of published topics like an archive. This shortcode accepts the following parameters:

  • orderby – can be ‘date’, ‘title’, ‘author’, ‘modified’, ‘rand’, or ‘comment_count’. With the Pro version, you can also use ‘freshness’ and ‘status’
    E.g.:[discussion_topics orderby="comment_count"] to display most commented-on topics
  • order – can be ‘ASC’ or ‘DESC’
  • number – the number of topics to display per page
  • show_nav – display navigation links
  • cols – can be ‘avatar,topic,replies,voices,freshness,status’
  • status – e.g. status=”Open” to only show topics with a status of ‘Open’

[discussion_board_login_form] – displays a log-in and registration form for new users

[discussion_board_login_only] – displays just the log-in form

[discussion_board_registration_only] – displays just the registration form

[discussion_board_log_in_out] – displays a log-in / log-out link

[is_logged_in]Wrap around text you only want to display to logged in users[/is_logged_in]

[not_logged_in]Wrap around text you only want to display to users who are not logged in[/not_logged_in]

[new_topic_button] – displays a link to the page with your New Topic form.

Display topics in table format

If you prefer to display your topics in a table layout rather than using the default archive templates, you need to add the [discussion_topics] shortcode to a page.

Then, go to Settings > Discussion Topics > Design and select ‘Table’ in the ‘Shortcode layout’ field.


Add a log-in form to the sidebar

You can add a log-in form to the sidebar by installing a plugin that will run shortcodes in widgets, e.g. Activate the plugin and add the widget to your sidebar. Use the [discussion_board_login_form] shortcode to insert your log-in and registration form.

How to change column titles in the discussion_topics shortcode

You can change column titles from the default like this:

function myprefix_change_ctdb_titles( $titles ) {
  $titles['started'] = 'Posted';
  return $titles;
add_filter( 'ctdb_topic_titles', 'myprefix_change_ctdb_titles' );

The default titles are:

$titles = array(
 'avatar' => '',
 'topic' => __( 'Topic', 'discussion-board' ),
 'replies' => __( 'Replies', 'discussion-board' ),
 'started' => __( 'Since', 'discussion-board' ),
 'posted-by' => __( 'Posted by: ', 'discussion-board' ),

Just replace with new values as required.

Extending the discussion_topics shortcode

You can add some more parameters to your [discussion_topics] shortcode in the Pro version.

[discussion_topics orderby="freshness" order="DESC" cols="avatar,topic,replies,voices,freshness" categories="4,9"]

You can use freshness in the orderby parameter to order your topics according to how recently they were updated – either posted or commented on.

You can add freshness to the cols parameter to include freshness in the table of topics.

You can also specify which categories to list by specifying the term_id for the categories in a comma-separated list. You can find the term_id by going to your dashboard then Topics > Topic Categories and hovering over the category you wish to include. The term_id is revealed in the URL.

Remember: you might need to enable categories in Discussion Board > Settings > Categories.