Skip Navigation

[Resolved] Trying to show custom taxonomies using shortcode in visual composer

This support ticket is created 7 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by johnh-18 7 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#467981
1.png
2.png
3.png
4.png

I have created two custom taxonomies for the ‘portfolio’ post type using toolset.
Using visual composer and ‘post grid’ (using ‘portfolio’ as data source), I created this page - hidden link

What I want to do is to show the (linked) custom taxonomies below the read more button and this is how I understand it should be done (but it does not work)
- I added a text block to the ‘additional block’
- clicked ‘fields and views’, selected the correct display options and then clicked ‘insert shortcake’ (attachment 1-3)
- saved updated / the admin pages - (attachments 1-3)
- opened VC ’shortcode mapper’ and entered the same short code as entered in the text block mentioned above, clicked 'parse' which generated the error message 'Please enter valid shortcode to parse!'. (attachment 4)

I have tried this a few times, also using posts as data source but same thing happens.

I have also tried to create 'views' in toolset and selected the 'view' after clicking 'fields and views' as described above but same result.

#468153

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screen Shot 2016-12-16 at 08.58.15.png

Hi John

I spent some time trying to get this to work before concluding it is not possible (not without digging deep into the Visual Composer core code).

I set up a test site to match what you are describing.

I edited the grid to add a text box where I could insert shortcodes. For testing I registered a simple shortcode that just spits out some dummy text, and as you can see from the screenshot, that worked fine. You don't need to register the shortcodes, they just work here.

There is a limitation with VC in that when designing your grid, of the various elements you can insert, you can insert the categories. The problem is that you can only insert standard WordPress categories, and not custom taxonomy terms. You might want to contact them to ask that this be added, although in your case the taxonomy is registered by Types it is a standard feature of WordPress.

The problem with shortcodes added in a text module in this grid design is one of context. When the page is loaded with the grid, VC makes an ajax request to get the posts to build the grid. It does this with a custom query, but it is fairly opaque, I can't see its workings. But it is not operating a standard WordPress loop, which is what the views taxonomy shortcode expects and which is why it fails here.

I thought it might be possible to use a custom shortcode to retrieve the terms of the current post and output the links, but there is no current post in the normal sense. Without combing through the VC codebase I don't know how they iterate across the posts to construct the grid to be able to have a way of knowing what post to retrieve the taxonomy terms for.

I'm sorry I can't be more helpful, as I say I would suggest they modify the category element so that it works with custom taxonomies as well as standard categories.

#468171

Hi Nigel,
Many thanks for your extensive response.
Two related questions
1.
Would it be possible to build a similar looking page used toolset and if yes, would that page then be able to do what I am trying to achieve?
2.
I have still not had time to explore toolset but I understand that you can build search and search results pages - would a search functionality built using toolset be capable of using the custom taxonomies as search criteria (this is in a way more important than being able to show the names of the taxonomies)
Best regards/john

#468326

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi John

Views doesn't do styling. It will generate whatever markup you specify for your output, which includes adding CSS classes, but it doesn't have anything to say about the styles themselves.

The only proviso here is that it will use Bootstrap classes for a grid system when you use the Loop Output Wizard to generate the markup for a View output and specify a Bootstrap grid.

So one of the nice things about using something like Visual Composer is that it comes with visual bells and whistles, such as the posts in the grid view fading in in a staggered fashion.

With that in mind, yes, you can build a page like you are describing with the missing taxonomies (and whatever else you want to include) using Toolset, but how it looks will in large part be determined by your theme and the additional styling you apply.

Note that you theme will undoubtedly come with CSS rules that you can re-use without having to re-invent the wheel. You can inspect the output of the VC grid page, for example, and replicate the same markup and classes in your View output to achieve a similar look.

And, yes, you can add custom search filters to your views or to your custom post archives.

We have a timely blog post about just that published today: https://toolset.com/2016/12/filter-custom-post-types-taxonomy-custom-fields/

Also check the following documentation pages about designing your View output:

https://toolset.com/documentation/user-guides/view-layouts-101/
https://toolset.com/documentation/user-guides/digging-into-view-outputs/

#468337

OK , many thanks / john

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.