Support » Plugin: teachPress » Image Shortcode in Post

  • Is there a way to display an image by shortcode in an automatically generated post from a publication? So to integrate the picture automatically in the contribution template?


    [tpsingle [key]]<!--more-->
    *Picture Here*

    WordPress 4.8.1
    teachPress 6.1.0

    • This topic was modified 9 months, 3 weeks ago by  guennionline.
Viewing 1 replies (of 1 total)
  • Plugin Author winkm89



    The following code should add an [tppubimage] shortcode. You can add the code to the functions.php of your theme or create a new plugin with it:

     * Shortcode for displaying the image of a single publication
     * possible values of $atts:
     *      id (INT)        id of a publication
     *      key (STRING)    bibtex key of a publication 
     * If neither is given, the publication of the most recent [tpsingle] will be reused
     * @param array $atts
     * @return string
    function tp_pubimage_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 '<img src="' . tp_html::prepare_text($publication['image_url']) . '" alt=""/>';
    add_shortcode('tppubimage', 'tp_pubimage_shortcode');
Viewing 1 replies (of 1 total)
  • The topic ‘Image Shortcode in Post’ is closed to new replies.