Title: Shortcode
Last modified: May 12, 2022

---

# Shortcode

 *  Resolved [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/)
 * (@nicoleamanda)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/shortcode-882/)
 * Newbie question – I know it involves php and/or shortcode and am having trouble
   finding it in the forum. What would I use to call (and display) the specific 
   custom taxonomies in single post that are associated with that single post?
 * Ex: colours taxonomy
    Single post has blue and red checked out of several colours
   Post displays <u>Blue</u> <u>Red</u>

Viewing 13 replies - 16 through 28 (of 28 total)

[←](https://wordpress.org/support/topic/shortcode-882/?output_format=md) [1](https://wordpress.org/support/topic/shortcode-882/?output_format=md)
2

 *  Plugin Author [nwjames](https://wordpress.org/support/users/nwjames/)
 * (@nwjames)
 * [4 years ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15730399)
 * [@nicoleamanda](https://wordpress.org/support/users/nicoleamanda/),
    I took a
   look at the plugin Taxonomy Images by Michael Fields and Ben Huson. I hope that
   that is the one you mean. They essentially require you to have some code to create
   the display.
 * I have tried this by using this code – which I have created as a plugin that 
   you install.
    1. Create a folder called `taxonomy-image-integration` in your plugins directory.
    2.  Create in it a file called `taxonomy-image-integration.php` with content:
    3.     ```
           <?php
           /**
           Plugin Name: Taxonomy Image Integration
           Description: Taxonomy Image Integration.
           Version: 1.0
           Author: Neil James
           License: GPL3
            */
       
           function tii_post_terms( $atts ) {
             $tax = shortcode_atts(
               array(
                 'tax' => '',
               ),
               $atts
             );
       
             global $post;
       
             if ( ! isset( $post->post_type ) ) {
               return;
             }
       
             if ( 'colours' === $tax['tax'] ) {
               echo apply_filters(
                 'taxonomy-images-list-the-terms',
                 '',
                 array(
                   'before'       => '<div class="colours-class">',
                   'after'        => '</div>',
                   'before_image' => '<span>&nbsp;',
                   'after_image'  => '</span>',
                   'image_size'   => 'detail',
                   'post_id'      => $post->ID,
                   'taxonomy'     => 'colours',
                 )
               );
             }
           }
       
           add_shortcode( 'tii_post_terms', 'tii_post_terms' );
           ```
       
 * You can activate it and put the shortocde `tii_post_terms tax=colours` where 
   you wish.
 * My experience was that it worked but the images came out at the top of the post
   no matter where I put the shortcode (with the Block Editor). Your experience 
   may be different with WPBakery.
 * This may give you some pointers – but I’m not sure that I can help further. You
   should ask within the plugin support forums.
 * It does highlight that I should think about adding some logic to manipulate the
   output more directly though there are some issues to think about in the integration
   with the underlying WordPress processing called.
 * Hope this is of use,
    Neil James
 *  Thread Starter [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/)
 * (@nicoleamanda)
 * [4 years ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15734324)
 * Okay, once I get this working you will bw my favourite person ever. So it’s likely
   still my end that it’s not working because I have it noted as “color” some places
   and “colour” others so I’ve tried to modify it myself but still not working. 
   The slug is color so I took out the u everywhere in the code but still not working.
   Thoughts?
 *  Plugin Author [nwjames](https://wordpress.org/support/users/nwjames/)
 * (@nwjames)
 * [4 years ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15735653)
 * [@nicoleamanda](https://wordpress.org/support/users/nicoleamanda/),
    You need
   to put your taxonomy slug (be it color or colour or colours) identically in 3
   places:
    1. In the plug-in code here:
        `if ( 'colours' === $tax['tax'] ) {` and here: `'
       taxonomy' => 'colours',`
    2. In youe shortcode text
        `[tii_post_terms tax=colours]`
 * Note that I have taken your previous comment that you don’t need to surround 
   the shortcode parameter with quote marks within WPBakery.
 * I will be explicit on a couple of points.
 * By putting this text as a sub-directory within the plugin directory and naming
   the filw as a .php file, WP will treat it as a plugin. It should show up in the
   plugins list – and need to be activated just as a standard one does.
 * Clearly Taxonomy Images also needs to be activated for it to work.
 * The shortcode must be executed for it to work. It must be given the correct parameter
   to work. [in contrast to my plug-in shortcode which will output for all relevant
   custom taxonomies if no parameter is given.]
 * Some extra thoughts. The code has a parameter ‘image_size’ set to ‘detail’ (as
   given in the plug-in example). It worked for me, but is not a standard image 
   size. You could try changing it to ‘thumb’. I don’t know if it defaults to this–
   or I was just lucky,
 * When I had a post with two colour terms, the images were abutted one to the other.
   
   That is why I added `&nbsp;` to the ‘before_image’ in the code – to put a non-
   breaking space between the images.
 * Good Luck,
    Neil James
 *  Thread Starter [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/)
 * (@nicoleamanda)
 * [4 years ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15735967)
 * Oh my gosh you are my absolute favourite right now. It just needed the activation(
   I’m so new at this). Is there a place I can donate to your plug-ins?
 *  Thread Starter [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/)
 * (@nicoleamanda)
 * [4 years ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15736467)
 * Darn, hiccup. Wasn’t working, was still my manually entered ones showing up. 
   But would still love to donate for all your help while I try to figure out my
   issue ;P
 *  Plugin Author [nwjames](https://wordpress.org/support/users/nwjames/)
 * (@nwjames)
 * [4 years ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15736675)
 * [@nicoleamanda](https://wordpress.org/support/users/nicoleamanda/),
    Sorry that
   it hasn’t worked properly – but the images may come out at top or bottom.
 * Your pages have a lot of output, and you might miss it. Simplest is often to 
   view the page source (often Ctrl+U) and then use search to find the text `colours-
   class` (or whatever you have in the `before` parameter in the code). If it’s 
   in the output anywhere, then it’s working.
 * Very generous to offer a donation. if you would wish to, please give to our Lions
   Club via [https://www.helloasso.com/associations/lions-club-yvelines-heraldic/formulaires/1](https://www.helloasso.com/associations/lions-club-yvelines-heraldic/formulaires/1).
   It’s a small club and we raise money generally for handicapped children.
 * Regards,
    Neil James
 *  Thread Starter [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/)
 * (@nicoleamanda)
 * [4 years ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15736780)
 * Wonderful, will do. Don’t want you to do more work than you’ve already done for
   me, but I’ve just been playing around and was curious if its even possible to
   have a php in your original plugin > includes files that would turn the default
   taxonomies “included in content” to images?
    ex, where is class-simpletaxonomyrefreshed-
   widget is
 * I can play if its a yes, you’ve already done more than enough 🙂
 *  Thread Starter [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/)
 * (@nicoleamanda)
 * [4 years ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15736787)
 * Ignore that, lol it would be cool but for some reason when I have anything set
   to taxnonomies in content (even if its content not excerpt) it shows up in my
   excerpt and thats a whole new bucket of worms.
 *  Plugin Author [nwjames](https://wordpress.org/support/users/nwjames/)
 * (@nwjames)
 * [4 years ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15737659)
 * [@nicoleamanda](https://wordpress.org/support/users/nicoleamanda/),
    One more
   try.
 * Replace all the code in `taxonomy-image-integration.php` with:
 *     ```
       <?php
       /**
       Plugin Name: Taxonomy Image Integration
       Description: Taxonomy Image Integration.
       Version: 1.0
       Author: Neil James
       License: GPL3
        */
   
       add_filter( 'term_links-colours', 'tii_colours' );
   
       /**
        * Function to disable embeds
        *
        * @return string[]
        */
       function tii_colours( $links ) {
         global $post;
   
         $rlinks   = array();
         if ( ! isset( $post->post_type ) ) {
           return $rlinks;
         }
   
         $rlinks[] = apply_filters(
             'taxonomy-images-list-the-terms',
             '',
             array(
               'before'       => '<div class="colours-class">',
               'after'        => '</div>',
               'before_image' => '<span>',
               'after_image'  => '</span>&nbsp;',
               'image_size'   => 'detail',
               'post_id'      => $post->ID,
               'taxonomy'     => 'colours',
             )
           );
       	return $rlinks;
       }
       ```
   
 * Ensure that the plugin is activated.
 * Whenever the post terms are output, instead of them being text, they will be 
   the images.
 * This will be in the content or excerpt code as well as the shortcode staxo_post_terms
   or even the block equivalent.
 * If you were to want it for another taxonomy then you need to copy the entire 
   text and replace colours everywhere with the new slug.
 * It might be that you are getting terms in excerpt due to how WPBakery generates
   excerpts – but that’s a pure guess on my part.
 * Hope this is of use,
    Neil James
 *  Thread Starter [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/)
 * (@nicoleamanda)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15740533)
 * You are absolutely fabulous. The only problem I’m having with the base version
   of Taxonomy Images Refreshed is even if I have a taxonomy set to
 * > Display Terms with Posts > Content
 *  it makes my excerpt blank rather than the post text. I know this is another 
   issue all together and if this is my only problem, I can find a work around 😉
   Thank you for everything!!!
 *  Thread Starter [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/)
 * (@nicoleamanda)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15740634)
 * Oh man, I need to stop….lol I’m messing things up.
 * Or learn how to read. Tired mom brain. Thanks again! This is amazing.
    -  This reply was modified 3 years, 12 months ago by [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/).
    -  This reply was modified 3 years, 12 months ago by [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/).
 *  Thread Starter [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/)
 * (@nicoleamanda)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15757871)
 * May I bother you once more? I feel like the answer is no, but worth an ask. I’d
   REALLY love a way to reorder the taxonomies in the order that they appear in **/
   wp-admin/admin.php?page=staxo_settings** list (and I hope with that, the other
   than they appear in the default full tag list. Or would I have to recreate them
   in the order that I want them?
    -  This reply was modified 3 years, 11 months ago by [nicoleamanda](https://wordpress.org/support/users/nicoleamanda/).
 *  Plugin Author [nwjames](https://wordpress.org/support/users/nwjames/)
 * (@nwjames)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15759768)
 * [@nicoleamanda](https://wordpress.org/support/users/nicoleamanda/),
    Thanks for
   your question.
 * Could I ask you to please raise this as a new support request with a title something
   like “Changing the display order of Custom Taxonomies” since the question is 
   likely to be of more general interest than “Shortcode”.
 * Thanks in advance,
    Neil

Viewing 13 replies - 16 through 28 (of 28 total)

[←](https://wordpress.org/support/topic/shortcode-882/?output_format=md) [1](https://wordpress.org/support/topic/shortcode-882/?output_format=md)
2

The topic ‘Shortcode’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/simple-taxonomy-refreshed.svg)
 * [Simple Taxonomy Refreshed](https://wordpress.org/plugins/simple-taxonomy-refreshed/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-taxonomy-refreshed/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-taxonomy-refreshed/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-taxonomy-refreshed/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-taxonomy-refreshed/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-taxonomy-refreshed/reviews/)

## Tags

 * [display](https://wordpress.org/support/topic-tag/display/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)
 * [single post](https://wordpress.org/support/topic-tag/single-post/)

 * 28 replies
 * 2 participants
 * Last reply from: [nwjames](https://wordpress.org/support/users/nwjames/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/shortcode-882/page/2/#post-15759768)
 * Status: resolved