teachPress Shortcodes

Below, you’ll find a detailed guide on how to add the teachPress Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the teachPress Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the teachPress Plugin and the shortcodes it provides:

Plugin Icon
teachPress

"teachPress is a powerful WordPress plugin designed for educators. It seamlessly manages courses, students, publications, and more, turning your website into an efficient teaching platform."

★★★★☆ (22) Active Installs: 2000+ Tested with: 6.3.0 PHP Version: 7.0
Included Shortcodes:
  • [tpcloud]
  • [tplist]
  • [tpsingle]
  • [tpbibtex]
  • [tpabstract]
  • [tplinks]
  • [tpsearch]
  • [tpcite]
  • [tpref]

teachPress [tpcloud] Shortcode

The teachPress plugin shortcode ‘tpcloud’ generates a customizable publication list. It allows users to filter publications by multiple parameters like author, year, or tag. This shortcode enables advanced customization, from style to pagination, offering a tailored user experience.

Shortcode: [tpcloud]

Parameters

Here is a list of all possible tpcloud shortcode parameters and attributes:

  • user – specifies the user of the plugin
  • tag – tag assigned to the publications
  • tag_name – name of the assigned tag
  • type – type of publication
  • author – author of the publication
  • year – year of publication
  • years_between – years between publications
  • exclude – exclude certain publications
  • include – include certain publications
  • include_editor_as_author – includes editor as an author
  • order – order of publications
  • headline – headline of the publication
  • maxsize – maximum tag size
  • minsize – minimum tag size
  • tag_limit – limit number of tags
  • hide_tags – hide certain tags
  • exclude_tags – exclude certain tags
  • exclude_types – exclude certain publication types
  • image – image linked to the publication
  • image_size – size of the image
  • image_link – link of the image
  • anchor – anchor for the publication
  • author_name – how author’s name is displayed
  • editor_name – how editor’s name is displayed
  • author_separator – separates author names
  • editor_separator – separates editor names
  • style – style of publication list
  • template – template used for publication list
  • title_ref – how title is referenced
  • link_style – style of the link
  • date_format – format of the publication date
  • pagination – pagination of the publication list
  • entries_per_page – number of entries per page
  • sort_list – how the list is sorted
  • show_tags_as – how tags are displayed
  • show_author_filter – show filter by author
  • show_in_author_filter – show in author filter
  • show_type_filter – show filter by publication type
  • show_user_filter – show filter by user
  • show_search_filter – show search filter
  • show_year_filter – show filter by year
  • show_bibtex – show bibtex entry
  • container_suffix – suffix for the container
  • show_altmetric_donut – show altmetric donut
  • show_altmetric_entry – show altmetric entry
  • show_dimensions_badge – show dimensions badge
  • show_plumx_widget – show PlumX widget
  • use_jumpmenu – use the jump menu
  • use_as_filter – use as a filter
  • filter_class – class for the filter
  • custom_filter – custom filter for publications
  • custom_filter_label – label for the custom filter

Examples and Usage

Basic example – Display a simple tag cloud using the ‘tpcloud’ shortcode.

[tpcloud /]

Advanced examples

Display a tag cloud with a specific user’s tags, ordered by date, and with a maximum tag size of 40.

[tpcloud user="john" order="date DESC" maxsize=40 /]

Display a tag cloud with tags of a specific type, excluding certain tags, and limiting the number of tags to 20.

[tpcloud type="book" exclude_tags="tag1, tag2" tag_limit=20 /]

Display a tag cloud with tags from publications between certain years, and exclude certain publication types.

[tpcloud year="2010" years_between="2010,2020" exclude_types="type1, type2" /]

Display a tag cloud with tags from publications that include a specific author or editor, and show the author filter.

[tpcloud include="author1" include_editor_as_author=1 show_author_filter=1 /]

Display a tag cloud with a custom style and template, and show a specific number of entries per page.

[tpcloud style="custom" template="tp_template_2021" entries_per_page=10 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [tpcloud] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('tpcloud', 'tp_cloud_shortcode');

Shortcode PHP function:

function tp_cloud_shortcode($atts) {
    $atts = shortcode_atts(array(
        'user'                      => '',
        'tag'                       => '',
        'tag_name'                  => '',
        'type'                      => '',
        'author'                    => '',
        'year'                      => '',
        'years_between'             => '',
        'exclude'                   => '',
        'include'                   => '',
        'include_editor_as_author'  => 1,
        'order'                     => 'date DESC',
        'headline'                  => 1,
        'maxsize'                   => 35,
        'minsize'                   => 11,
        'tag_limit'                 => 30,
        'hide_tags'                 => '',
        'exclude_tags'              => '',
        'exclude_types'             => '',
        'image'                     => 'none',
        'image_size'                => 0,
        'image_link'                => 'none',
        'anchor'                    => 1,
        'author_name'               => 'initials',
        'editor_name'               => 'initials',
        'author_separator'          => ';',
        'editor_separator'          => ';',
        'style'                     => 'none',
        'template'                  => 'tp_template_2021',
        'title_ref'                 => 'links',
        'link_style'                => 'inline',
        'date_format'               => 'd.m.Y',
        'pagination'                => 1,
        'entries_per_page'          => 50,
        'sort_list'                 => '',
        'show_tags_as'              => 'cloud',
        'show_author_filter'        => 1,
        'show_in_author_filter'     => '',
        'show_type_filter'          => 1,
        'show_user_filter'          => 1,
        'show_search_filter'        => 0,
        'show_year_filter'          => 1,
        'show_bibtex'               => 1,
        'container_suffix'          => '',
        'show_altmetric_donut'      => 0,
        'show_altmetric_entry'      => 0,
        'show_dimensions_badge'     => 0,
        'show_plumx_widget'         => 0,
        'use_jumpmenu'              => 1,
        'use_as_filter'             => 1,
        'filter_class'              => 'default',
        'custom_filter'             => '',
        'custom_filter_label'       => '',
    ), $atts);

    return tp_publist_shortcode($atts);

}

Code file location:

teachpress/teachpress/teachpress.php

teachPress [tplist] Shortcode

The teachPress plugin ‘tplist’ shortcode is a versatile tool for displaying a publication list on your WordPress site. . It allows for extensive customization, including filtering by user, tag, type, author, and year. You can also alter the order, image settings, pagination, and more. It even supports various widgets and a jump menu for easy navigation.

Shortcode: [tplist]

Parameters

Here is a list of all possible tplist shortcode parameters and attributes:

  • user – specifies the user associated with the list
  • tag – defines the tag for filtering the list
  • tag_name – sets the name of the tag
  • type – sets the type of content to display
  • author – specifies the author of the content
  • year – defines the year of publication
  • years_between – sets a range between years
  • exclude – excludes specific items from the list
  • include – includes specific items in the list
  • include_editor_as_author – includes the editor as the author
  • exclude_tags – excludes specific tags
  • exclude_types – excludes specific types
  • order – sets the order of the list
  • headline – toggles the visibility of the headline
  • image – sets the display of the image
  • image_size – sets the size of the image
  • image_link – defines the link of the image
  • anchor – toggles the visibility of anchors
  • author_name – sets the display of the author’s name
  • editor_name – sets the display of the editor’s name
  • author_separator – sets the separator for authors
  • editor_separator – sets the separator for editors
  • style – defines the CSS style of the list
  • template – sets the template for the list
  • title_ref – defines the reference of the title
  • link_style – sets the style of the link
  • date_format – sets the format of the date
  • pagination – toggles the visibility of pagination
  • entries_per_page – sets the number of entries per page
  • sort_list – defines the sorting of the list
  • show_bibtex – toggles the display of BibTeX entries
  • show_type_filter – toggles the type filter
  • show_author_filter – toggles the author filter
  • show_in_author_filter – sets the author filter inclusion
  • show_search_filter – toggles the search filter
  • show_user_filter – toggles the user filter
  • show_year_filter – toggles the year filter
  • show_tags_as – sets the display of tags
  • container_suffix – sets the suffix for the container
  • show_altmetric_donut – toggles the display of Altmetric donuts
  • show_altmetric_entry – toggles the display of Altmetric entries
  • show_dimensions_badge – toggles the display of Dimensions badges
  • show_plumx_widget – toggles the display of PlumX widgets
  • use_jumpmenu – toggles the use of a jump menu
  • use_as_filter – toggles the use of the shortcode as a filter
  • filter_class – defines the CSS class for the filter

Examples and Usage

Basic example – Show a list of publications from a specific user

[tplist user="john_doe" /]

Advanced examples

Display a list of publications from a specific user, with a specific tag and order them by date in descending order.

[tplist user="john_doe" tag="php" order="date DESC" /]

Generate a list of publications excluding certain types and tags, and limit the entries per page to 20.

[tplist exclude_types="book,article" exclude_tags="php,wordpress" entries_per_page=20 /]

Show a list of publications from a specific author, for a specific year, and include the editor as the author.

[tplist author="john_doe" year="2021" include_editor_as_author=1 /]

Display a list of publications with a specific style and template, and show the bibtex.

[tplist style="minimalist" template="tp_template_2021" show_bibtex=1 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [tplist] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('tplist', 'tp_list_shortcode');

Shortcode PHP function:

function tp_list_shortcode($atts){
    $atts = shortcode_atts(array(
       'user'                       => '',
       'tag'                        => '',
       'tag_name'                   => '',
       'type'                       => '',
       'author'                     => '',
       'year'                       => '',
       'years_between'              => '',
       'exclude'                    => '',
       'include'                    => '',
       'include_editor_as_author'   => 1,
       'exclude_tags'               => '',
       'exclude_types'              => '',
       'order'                      => 'date DESC',
       'headline'                   => 1,
       'image'                      => 'none',
       'image_size'                 => 0,
       'image_link'                 => 'none',
       'anchor'                     => 1,
       'author_name'                => 'initials',
       'editor_name'                => 'initials',
       'author_separator'           => ';',
       'editor_separator'           => ';',
       'style'                      => 'none',
       'template'                   => 'tp_template_2021',
       'title_ref'                  => 'links',
       'link_style'                 => 'inline',
       'date_format'                => 'd.m.Y',
       'pagination'                 => 1,
       'entries_per_page'           => 50,
       'sort_list'                  => '',
       'show_bibtex'                => 1,
       'show_type_filter'           => 0,
       'show_author_filter'         => 0,
       'show_in_author_filter'      => '',
       'show_search_filter'         => 0,
       'show_user_filter'           => 0,
       'show_year_filter'           => 0,
       'show_tags_as'               => 'none',
       'container_suffix'           => '',
       'show_altmetric_donut'       => 0,
       'show_altmetric_entry'       => 0,
       'show_dimensions_badge'      => 0,
       'show_plumx_widget'          => 0,
       'use_jumpmenu'               => 1,
       'use_as_filter'              => 1,
       'filter_class'               => 'default'
    ), $atts);

    return tp_publist_shortcode($atts);
}

Code file location:

teachpress/teachpress/teachpress.php

teachPress [tpsingle] Shortcode

The teachpress plugin shortcode ‘tpsingle’ is used to display a single publication with specified attributes. It allows customization of author/editor names, separators, date format, and image details. If a publication key is provided, it fetches the publication by key; otherwise, it uses the id. The shortcode also supports linking the publication title to a URL and customizing the display of publication metadata.

Shortcode: [tpsingle]

Parameters

Here is a list of all possible tpsingle shortcode parameters and attributes:

  • id – Specifies the unique ID of the publication.
  • key – The unique key of the publication.
  • author_name – Defines the display style of the author’s name.
  • author_separator – The separator used between author names.
  • editor_separator – The separator used between editor names.
  • editor_name – Defines the display style of the editor’s name.
  • date_format – Sets the format for the date display.
  • image – Determines the position of the image (none, left, right).
  • image_size – Sets the size of the image.
  • meta_label_in – Label for the ‘In’ metadata field.
  • link – Defines whether a link should be added to the title.

Examples and Usage

Basic example – Show a single publication by using its ID

[tpsingle id=1 /]

Advanced examples

Display a single publication with a specified author name format, author separator, and a custom date format.

[tpsingle id=1 author_name='last' author_separator=' and ' date_format='F j, Y' /]

Show a single publication with an image on the left side and with a specific size.

[tpsingle id=1 image='left' image_size=150 /]

Display a single publication by using its key instead of ID.

[tpsingle key='pubKey123' /]

Present a single publication with a link to the original source.

[tpsingle id=1 link='yes' /]

Remember, you can combine multiple parameters to customize the output to your needs. Also, make sure to replace the example values with the actual values you want to use.

PHP Function Code

In case you have difficulties debugging what causing issues with [tpsingle] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('tpsingle', 'tp_single_shortcode');

Shortcode PHP function:

function tp_single_shortcode ($atts) {
    global $tp_single_publication;
    $param = shortcode_atts(array(
       'id'                 => 0,
       'key'                => '',
       'author_name'        => 'simple',
       'author_separator'   => ',',
       'editor_separator'   => ';',
       'editor_name'        => 'last',
       'date_format'        => 'd.m.Y',
       'image'              => 'none',
       'image_size'         => 0,
       'meta_label_in'      => __('In','teachpress') . ': ',
       'link'               => ''
    ), $atts);

    $settings = array(
       'author_name'        => htmlspecialchars($param['author_name']),
       'editor_name'        => htmlspecialchars($param['editor_name']),
       'author_separator'   => htmlspecialchars($param['author_separator']),
       'editor_separator'   => htmlspecialchars($param['editor_separator']),
       'date_format'        => htmlspecialchars($param['date_format']),
       'style'              => 'simple',
       'meta_label_in'      => htmlspecialchars($param['meta_label_in']),
       'use_span'           => true
    );

    // Set publication
    if ( $param['key'] != '' ) {
        $publication = TP_Publications::get_publication_by_key($param['key'], ARRAY_A);
    }
    else {
        $publication = TP_Publications::get_publication($param['id'], ARRAY_A);
    }
    $tp_single_publication = $publication;

    // Set author name
    if ( $publication['type'] === 'collection' || $publication['type'] === 'periodical' || ( $publication['author'] === '' && $publication['editor'] !== '' ) ) {
        $author = TP_Bibtex::parse_author($publication['editor'], $settings['author_separator'], $settings['editor_name'] ) . ' (' . __('Ed.','teachpress') . ')';
    }
    else {
        $author = TP_Bibtex::parse_author($publication['author'], $settings['author_separator'], $settings['author_name'] );
    }

    $image_size = intval($param['image_size']);

    $asg = '<div class="tp_single_publication">';

    // add image
    if ( ( $param['image'] === 'left' || $param['image'] === 'right' ) && $publication['image_url'] != '' ) {
        $class = ( $param['image'] === 'left' ) ? 'tp_single_image_left' : 'tp_single_image_right';
        $asg .= '<div class="' . $class . '"><img name="' . $publication['title'] . '" src="' . $publication['image_url'] . '" width="' . $image_size .'" alt="" /></div>';
    }

    // define title
    if ( $param['link'] !== '' && $publication['url'] !== '' ) {
        // Use the first link in url field without the original title
        $url = explode(chr(13) . chr(10), $publication['url']);
        $parts = explode(', ',$url[0]);
        $parts[0] = trim( $parts[0] );
        $title = '<a href="' . $parts[0] . '">' . TP_HTML::prepare_title($publication['title'], 'decode') . '</a>';
    }
    else {
        $title = TP_HTML::prepare_title($publication['title'], 'decode');
    }
    $asg .= '<span class="tp_single_author">' . stripslashes($author) . ': </span> <span class="tp_single_title">' . $title . '</span>. <span class="tp_single_additional">' . TP_HTML_Publication_Template::get_publication_meta_row($publication, $settings) . '</span>';
    $asg .= '</div>';
    return $asg;
}

Code file location:

teachpress/teachpress/teachpress.php

teachPress [tpbibtex] Shortcode

The ‘tpbibtex’ shortcode from the teachpress plugin is designed to display the BibTeX of a specific publication. This shortcode fetches the BibTeX data of a publication via its ID or key. It also offers the option to download the BibTeX data. The shortcode checks the plugin’s setting to decide whether to convert the BibTeX data or not. The data is then presented in a pre-formatted text block, providing a neat and structured display of the BibTeX data.

Shortcode: [tpbibtex]

Parameters

Here is a list of all possible tpbibtex shortcode parameters and attributes:

  • id – Numeric value serving as the unique identifier for the publication
  • key – Specific key associated with the publication

Examples and Usage

Basic example – Showcases a simple usage of the ‘tpbibtex’ shortcode, where we are only using the ‘id’ attribute.

[tpbibtex id=1 /]

Advanced examples

1. In this example, we are using both ‘id’ and ‘key’ attributes. The shortcode will first try to load the publication by ID, but if not found, it will try to load by key.

[tpbibtex id=1 key='sample-key' /]

2. Here, we are only using the ‘key’ attribute. The shortcode will load the publication by key.

[tpbibtex key='sample-key' /]

These examples demonstrate the flexibility of the ‘tpbibtex’ shortcode, allowing you to reference publications in different ways based on your needs.

PHP Function Code

In case you have difficulties debugging what causing issues with [tpbibtex] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('tpbibtex', 'tp_bibtex_shortcode');

Shortcode PHP function:

function tp_bibtex_shortcode ($atts) {
    global $tp_single_publication;
    $param = shortcode_atts(array(
       'id' => 0,
       'key' => '',
    ), $atts);

    $convert_bibtex = ( get_tp_option('convert_bibtex') == '1' ) ? true : false;
    $publication = TP_Shortcodes::set_publication($param, $tp_single_publication);

    $tags = TP_Tags::get_tags( array('pub_id' => $publication['pub_id'], 'output_type' => ARRAY_A) );

    return '<h2 class="tp_bibtex">BibTeX (<a href="' . home_url() . '?feed=tp_pub_bibtex&amp;key=' . $publication['bibtex'] . '">Download</a>)</h2><pre class="tp_bibtex">' . TP_Bibtex::get_single_publication_bibtex($publication, $tags, $convert_bibtex) . '</pre>';
}

Code file location:

teachpress/teachpress/teachpress.php

teachPress [tpabstract] Shortcode

The teachpress plugin shortcode ‘tpabstract’ displays the abstract of a specific publication. It takes in ‘id’ and ‘key’ parameters to identify the publication. The ‘tp_abstract_shortcode’ function fetches the publication data. If an ‘abstract’ field exists, it returns a formatted HTML string containing the abstract, wrapped in ‘h2’ and ‘p’ tags for styling.

Shortcode: [tpabstract]

Parameters

Here is a list of all possible tpabstract shortcode parameters and attributes:

  • id – Unique identifier for the specific publication
  • key – Optional parameter to filter the publication

Examples and Usage

Basic example – A simple usage of the ‘tpabstract’ shortcode to display the abstract of a publication by referencing its ID.

[tpabstract id=1 /]

Advanced examples

Here, the ‘tpabstract’ shortcode is used to display the abstract of a publication by referencing its unique key. If the publication with the given key is found, the abstract for that publication will be displayed.

[tpabstract key='unique_publication_key' /]

In this advanced example, the ‘tpabstract’ shortcode is used with both the ‘id’ and ‘key’ parameters. The shortcode will first try to find the publication using the ID. If the publication with the given ID is not found, it will then try to find the publication using the key.

[tpabstract id=1 key='unique_publication_key' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [tpabstract] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('tpabstract', 'tp_abstract_shortcode');

Shortcode PHP function:

function tp_abstract_shortcode ($atts) {
    global $tp_single_publication;
    $param = shortcode_atts(array(
       'id' => 0,
       'key' => '',
    ), $atts);

    $publication = TP_Shortcodes::set_publication($param, $tp_single_publication);

    if ( isset($publication['abstract']) ) {
        return '<h2 class="tp_abstract">' . __('Abstract','teachpress') . '</h2><p class="tp_abstract">' . TP_HTML::prepare_text($publication['abstract']) . '</p>';
    }
    return;
}

Code file location:

teachpress/teachpress/teachpress.php

teachPress [tplinks] Shortcode

The teachpress plugin shortcode ‘tplinks’ is designed to display publication links. It fetches the URL and DOI of a specific publication and presents it in a user-friendly format. This shortcode takes two parameters: ‘id’ and ‘key’. The ‘id’ parameter is used to specify the publication ID, while ‘key’ remains unused in this function. If a URL exists for the given publication ID, it returns a formatted HTML string containing the publication’s links.

Shortcode: [tplinks]

Parameters

Here is a list of all possible tplinks shortcode parameters and attributes:

  • id – Specifies the unique identifier of the publication
  • key – Optional parameter, remains unused in this shortcode

Examples and Usage

Basic example – The shortcode is used to display a specific publication link by referencing its ID.

[tplinks id=1 /]

Advanced examples

In the following example, the shortcode is used to display a specific publication link by referencing both its ID and key. The publication will first try to load by ID, but if not found, it will try to load by key.

[tplinks id=1 key='publication_key' /]

In another advanced usage, the shortcode is used without any parameters. In this case, it will display the link of the last published publication.

[tplinks /]

PHP Function Code

In case you have difficulties debugging what causing issues with [tplinks] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('tplinks', 'tp_links_shortcode');

Shortcode PHP function:

function tp_links_shortcode ($atts) {
    global $tp_single_publication;
    $param = shortcode_atts(array(
       'id' => 0,
       'key' => '',
    ), $atts);

    $publication = TP_Shortcodes::set_publication($param, $tp_single_publication);

    if ( isset($publication['url']) ) {
        return '<h2 class="tp_links">' . __('Links','teachpress') . '</h2><p class="tp_abstract">' . TP_HTML_Publication_Template::prepare_url($publication['url'], $publication['doi'], 'list') . '</p>';
    }
    return;
}

Code file location:

teachpress/teachpress/teachpress.php

teachPress [tpsearch] Shortcode

The ‘tpsearch’ shortcode from the teachpress plugin allows users to customize and filter search results on their WordPress site. The shortcode includes numerous attributes, each specifying a different aspect of the search function. These attributes range from user-specific filters, date and order of results, to display settings like image size and pagination. This provides users with a highly adaptable search tool tailored to their needs.

Shortcode: [tpsearch]

Parameters

Here is a list of all possible tpsearch shortcode parameters and attributes:

  • user – specifies the user for the search
  • tag – specifies the tag for the search
  • tag_name – specifies the tag name for the search
  • type – specifies the type of content for the search
  • author – specifies the author for the search
  • year – specifies the year for the search
  • years_between – specifies the years range for the search
  • exclude – excludes specified content from the search
  • include – includes specified content in the search
  • include_editor_as_author – includes the editor as an author in the search
  • order – sets the order of the search results
  • headline – sets whether to include headlines in the search
  • exclude_tags – excludes specified tags from the search
  • exclude_types – excludes specified types from the search
  • image – includes an image in the search
  • image_size – sets the size of the image in the search
  • image_link – includes a link to the image in the search
  • anchor – includes an anchor in the search
  • author_name – sets the display style of the author’s name
  • editor_name – sets the display style of the editor’s name
  • author_separator – sets the separator for multiple authors
  • editor_separator – sets the separator for multiple editors
  • style – sets the style of the search
  • template – sets the template for the search
  • title_ref – sets the reference style for titles
  • link_style – sets the style for links
  • date_format – sets the format for dates
  • pagination – enables or disables pagination
  • entries_per_page – sets the number of entries per page
  • sort_list – sets the sort order of the list
  • show_bibtex – sets whether to show bibtex entries
  • show_tags_as – sets how tags are displayed
  • show_author_filter – sets whether to show the author filter
  • show_in_author_filter – sets what to show in the author filter
  • show_type_filter – sets whether to show the type filter
  • show_user_filter – sets whether to show the user filter
  • show_search_filter – sets whether to show the search filter
  • show_year_filter – sets whether to show the year filter
  • container_suffix – sets a suffix for the container
  • show_altmetric_donut – sets whether to show the altmetric donut
  • show_altmetric_entry – sets whether to show the altmetric entry
  • show_dimensions_badge – sets whether to show the dimensions badge
  • show_plumx_widget – sets whether to show the plumx widget
  • use_jumpmenu – sets whether to use a jump menu
  • use_as_filter – sets whether to use as a filter
  • filter_class – sets the class for the filter
  • custom_filter – allows for a custom filter
  • custom_filter_label – sets the label for the custom filter

Examples and Usage

Basic example – A simple use case of the tpsearch shortcode to display a search box with default settings.

[tpsearch /]

Advanced examples

Display a search box with a specific user, type, and order of results. The shortcode will return the results for the user with the username ‘john_doe’, of type ‘book’, and ordered by date in descending order.

[tpsearch user='john_doe' type='book' order='date DESC' /]

Display a search box with a custom template, entries per page, and show a BibTex button. This shortcode will use the ‘tp_template_2021’ template, display 10 entries per page, and show a BibTex button for each entry.

[tpsearch template='tp_template_2021' entries_per_page='10' show_bibtex='1' /]

Display a search box with filters for author, year, and search. This shortcode will show filters for the author, year, and a search box, allowing users to refine their search results.

[tpsearch show_author_filter='1' show_year_filter='1' show_search_filter='1' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [tpsearch] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('tpsearch', 'tp_search_shortcode');

Shortcode PHP function:

function tp_search_shortcode ($atts) {
    $atts = shortcode_atts(array(
       'user'                       => '',
       'tag'                        => '',
       'tag_name'                   => '',
       'type'                       => '',
       'author'                     => '',
       'year'                       => '',
       'years_between'              => '',
       'exclude'                    => '',
       'include'                    => '',
       'include_editor_as_author'   => 1,
       'order'                      => 'date DESC',
       'headline'                   => 0,
       'exclude_tags'               => '',
       'exclude_types'              => '',
       'image'                      => 'none',
       'image_size'                 => 0,
       'image_link'                 => 'none',
       'anchor'                     => 0,
       'author_name'                => 'initials',
       'editor_name'                => 'initials',
       'author_separator'           => ';',
       'editor_separator'           => ';',
       'style'                      => 'numbered',
       'template'                   => 'tp_template_2021',
       'title_ref'                  => 'links',
       'link_style'                 => 'inline',
       'date_format'                => 'd.m.Y',
       'pagination'                 => 1,
       'entries_per_page'           => 20,
       'sort_list'                  => '',
       'show_bibtex'                => 1,
       'show_tags_as'               => 'none',
       'show_author_filter'         => 0,
       'show_in_author_filter'      => '',
       'show_type_filter'           => 0,
       'show_user_filter'           => 0,
       'show_search_filter'         => 1,
       'show_year_filter'           => 0,
       'container_suffix'           => '',
       'show_altmetric_donut'       => 0,
       'show_altmetric_entry'       => 0,
       'show_dimensions_badge'      => 0,
       'show_plumx_widget'          => 0,
       'use_jumpmenu'               => 0,
       'use_as_filter'              => 1,
       'filter_class'               => 'block',
       'custom_filter'              => '',
       'custom_filter_label'        => '',
    ), $atts);

    return tp_publist_shortcode($atts);
}

Code file location:

teachpress/teachpress/teachpress.php

teachPress [tpcite] Shortcode

The teachPress shortcode ‘tpcite’ is designed to add citations to your posts. This shortcode retrieves a publication by its ID or key and adds a reference to it. It then returns a superscript link to the citation. The shortcode accepts two parameters: ‘id’ and ‘key’. If ‘key’ is provided, it fetches the publication by key. If not, it retrieves the publication by ‘id’. The returned link is anchored to the publication’s ID, allowing readers to quickly navigate to the cited source.

Shortcode: [tpcite]

Parameters

Here is a list of all possible tpcite shortcode parameters and attributes:

  • id – Unique identifier for the publication
  • key – Alternative key to locate the publication

Examples and Usage

Basic example – A shortcode that references a publication by its id.

[tpcite id=1 /]

Advanced examples

Using the shortcode to reference a publication by its key. If the publication with the specified key is found, it will be cited in the content.

[tpcite key='pub_key' /]

Using the shortcode to reference a publication by both its id and key. The publication will first try to load by id, but if not found, it will try to load by key.

[tpcite id=1 key='pub_key' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [tpcite] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('tpcite', 'tp_cite_shortcode');

Shortcode PHP function:

function tp_cite_shortcode ($atts) {
    global $tp_cite_object;
    $param = shortcode_atts(array(
       'id' => 0,
       'key' => ''
    ), $atts);

    // Load cite object
    if ( !isset($tp_cite_object) ) {
        $tp_cite_object = new TP_Cite_Object;
    }

    // Check parameter
    if ( $param['key'] != '' ) {
        $publication = TP_Publications::get_publication_by_key($param['key'], ARRAY_A);
    }
    else {
        $publication = TP_Publications::get_publication($param['id'], ARRAY_A);
    }

    // Add ref to cite object
    $index = $tp_cite_object->add_ref($publication);

    // Return
    return '<sup><a href="#tp_cite_' . $publication['pub_id'] . '">[' . $index . ']</a></sup>';
}

Code file location:

teachpress/teachpress/teachpress.php

teachPress [tpref] Shortcode

The teachpress shortcode ‘tpref’ is designed to display a list of references in a post. It utilizes various parameters such as author name, editor name, date format, and link display to customize the output. The shortcode fetches reference data, formats it according to the defined settings, and presents it as an ordered list under the heading ‘References’. If no references are found, it returns nothing.

Shortcode: [tpref]

Parameters

Here is a list of all possible tpref shortcode parameters and attributes:

  • author_name – Defines the display style of the author’s name.
  • editor_name – Determines the display style of the editor’s name.
  • author_separator – Specifies the separator for multiple authors.
  • editor_separator – Specifies the separator for multiple editors.
  • date_format – Sets the format for the date display.
  • show_links – Controls the display of links, 1 for show, 0 for hide.

Examples and Usage

Basic example – A simple usage of tpref shortcode without any parameters. This will use the default parameter values defined in the shortcode function.

[tpref /]

Advanced examples

Using the tpref shortcode with the ‘author_name’ parameter. This will display the author’s name in a simple format.

[tpref author_name="simple" /]

Using the tpref shortcode with multiple parameters. This example includes ‘author_name’, ‘editor_name’, ‘author_separator’, ‘editor_separator’, and ‘date_format’. These parameters will customize how the author’s name, editor’s name, the separator between authors and editors, and the date format are displayed.

[tpref author_name="simple" editor_name="initials" author_separator="," editor_separator=";" date_format="d.m.Y" /]

Using the tpref shortcode with the ‘show_links’ parameter set to 1. This will enable the display of direct links to the references.

[tpref show_links="1" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [tpref] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('tpref','tp_ref_shortcode');

Shortcode PHP function:

function tp_ref_shortcode($atts) {
    global $tp_cite_object;

    // shortcode parameter defaults
    $param = shortcode_atts(array(
       'author_name'        => 'simple',
       'editor_name'        => 'initials',
       'author_separator'   => ',',
       'editor_separator'   => ';',
       'date_format'        => 'd.m.Y',
       'show_links'         => 0
    ), $atts);

    // define settings
    $settings = array(
       'author_name'        => htmlspecialchars($param['author_name']),
       'editor_name'        => htmlspecialchars($param['editor_name']),
       'author_separator'   => htmlspecialchars($param['author_separator']),
       'editor_separator'   => htmlspecialchars($param['editor_separator']),
       'date_format'        => htmlspecialchars($param['date_format']),
       'style'              => 'simple',
       'title_ref'          => 'links',
       'link_style'         => ($param['show_links'] == 1) ? 'direct' : 'none',
       'meta_label_in'      => __('In','teachpress') . ': ',
       'use_span'           => false
    );

    // define reference part
    $references = isset($tp_cite_object) ? $tp_cite_object->get_ref() : array();

    // If there is no reference to show
    if ( empty($references) ) {
        return;
    }

    $ret = '<h3 class="teachpress_ref_headline">' . __('References','teachpress') . '</h3>';
    $ret .= '<ol>';
    foreach ( $references as $row ) {
        $ret .= '<li id="tp_cite_' . $row['pub_id'] . '" class="tp_cite_entry"><span class="tp_single_author">' . stripslashes($row['author']) . '</span><span class="tp_single_year"> (' . $row['year'] . ')</span>: <span class="tp_single_title">' . TP_HTML_Publication_Template::prepare_publication_title($row, $settings, 1) . '</span>. <span class="tp_single_additional">' . TP_HTML_Publication_Template::get_publication_meta_row($row, $settings) . '</span></li>';
    }
    $ret .= '</ol>';
    return $ret;
}

Code file location:

teachpress/teachpress/teachpress.php

Conclusion

Now that you’ve learned how to embed the teachPress Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *