Shortcode
-
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>
-
@nicoleamanda
Thank you for your question.Assume you have a taxonomy with slug colours (set on Main tab) and name Colours (on Labels tab) – and for completeness query_var colour (on Other tab).
For a post that has blue and red checked, then to get them appears on thr Post page under the content, please set the field “Display Terms with Posts” to “Content” or “Content and Excerpt”.
This will give a comma-separated list of Terms, i.e. Blue, Red
Each term will also include a link to all posts with that Term. E.g. site/?colour=blue
[colour is the query var value referred to above.]If you would like to see the text Colours : Blue, Red then you should enter “Colours :” in “Display Terms Before text”
Note that the terms list uses an html class of “taxonomy-colours” for you to be able to do some css styling.
Hope that this helps,
Neil JamesThanks so much! Didn’t see this change as I had been using the old version of the plugin until now. Is there a way to get a php or shortcode for them so that I can put them somewhere mid post? I know that’s probably more in depth to ask ??
@nicoleamanda
If I remember correctly, this functionality was in the original version, but didn’t work.If you are able to enter PHP into your post template and you don’t use excerpts for the post type, you could define “Display Terms with Posts” to be “excerpt”. In this way it won’t appear at the end of content.
Then where you want the Terms to appear, put
<?php echo SimpleTaxonomyRefreshed_Client::the_excerpt(); ?>
Hope this is of use,
Neil JamesUnfortunately the way my theme is build, it overwrites any other PHP when I save a change to the design. I’ll try to see if this would work in a plugin that converts to shortcode. Thanks so much for your time!
@nicoleamanda
If you are able to go to the GitHub repository https://github.com/NeilWJames/simple-taxonomy-refreshed and download the zip file (found from button “Code”). In it you will find a filesimple-taxonomy-refreshed-master/includes/class-simple-taxonomy-refreshed-client.php
You can take ONLY this file and upload this to replace the same file within the plugin on the WordPress site. If you do this, then you have available a shortcode
[str_post_terms tax=slug]
The tax parameter is optional – in which case all plugin taxonomies will be output.
The “before” and “after” text will be used. The Display option process is unchanged, so probably should be set to None.
Regards,
Neil James@nicoleamanda ,
Version 2.2.0 released just now addresses this with either a shortcode or a block.The shortcode name has bee changed to
staxo_post_terms
to be more consistent with other uses of the plugin name.Regards,
NeilThanks so much. I’m not sure if I did it right, I’m such a newbie lol
The ones before xoxo, Nicole at the bottom are the default at the end of the post. The shortcode under the paragraph isn’t showing up
https://nicoleamanda.ca/aquatopia-water-garden-conservatory-wedding/
-
This reply was modified 2 years, 9 months ago by
nicoleamanda.
@nicoleamanda
I see that you’re trying to get this to work now (and making some changes).In the version I see now, it has:
[staxo_post_terms tax=”styles”] [s
<p>[<span class=”vc_preview-tag”>staxo_post_terms</span> <span class=”vc_preview-param”>tax=”styles”</span>] [<span class=”vc_preview-tag”>staxo_post_terms</span> <span class=”vc_preview-param”>tax=”settings” </span>[<span class=”vc_preview-tag”>staxo_post_terms</span> <span class=”vc_preview-param”>tax=”seasons”</span>] [<span class=”vc_preview-tag”>staxo_post_terms</span> <span class=”vc_preview-param”>tax=”colors”</span>]</p><p>[<span class=”vc_preview-tag”>staxo_post_terms</span>]</p>`taxo_post_terms tax=”settings” [staxo_post_terms tax=”seasons”] [staxo_post_terms tax=”colors”][staxo_post_terms]`
under the initial paragraph.
However the text that is being sent to the browser is:
<p>[<span class="vc_preview-tag">staxo_post_terms</span> <span class="vc_preview-param">tax=”styles”</span>] [<span class="vc_preview-tag">staxo_post_terms</span> <span class="vc_preview-param">tax=”settings” </span>[<span class="vc_preview-tag">staxo_post_terms</span> <span class="vc_preview-param">tax=”seasons”</span>] [<span class="vc_preview-tag">staxo_post_terms</span> <span class="vc_preview-param">tax=”colors”</span>]</p><p>[<span class="vc_preview-tag">staxo_post_terms</span>]</p>
So there is some manipulation of the shortcode text that is happening. And it is not being processed as a shortcode.
You appear to be using WPBakery Page Builder. Possibly there is some advice you can get from them.
The text entered looks correct for me.
Sorry that I cannot be of more help.
Neil James@nicoleamanda
Sorry, what appears on the screen is:[staxo_post_terms tax=”styles”] [staxo_post_terms tax=”settings” [staxo_post_terms tax=”seasons”] [staxo_post_terms tax=”colors”] [staxo_post_terms]
That is, looks like the shortcode text required.
Regards,
NeilOkay, thanks so much for confirming. I’ll dig into that ?? WPBakery has a shortcode mapper, but that didn’t work either
You’re right its wpbakery I tried it without
I can get [staxo_post_terms] to work in it but not the individual tax
@nicoleamanda,
Glad that you’re able to get something.[staxo_post_terms] will give you all the custom term – but in the order of taxonomies that they are stored in the parameter list. You can use the individual ones not just to control whether you want specific ones, but also but outputting them individually, you can control the order.
A thought though. Thke one of these with a parameter:
[<span class="vc_preview-tag">staxo_post_terms</span> <span class="vc_preview-param">tax=”styles”</span>]
Tag corresponds to hte shortcode. But the param for me is not
tax=”styles”
, it is justtax
. You then add the parameter value (herestyles
) where needed. Could be set as a default.Hope this helps,
NeilOh gotcha. Lost the quotes and it worked. Not sure why I did that. Thanks SO much!!!!
Long shot – I know it’s a separate plugin, but would you happen to know how to call the taxonomy images plugin if I had a colours taxonomy?
-
This reply was modified 2 years, 9 months ago by
- The topic ‘Shortcode’ is closed to new replies.