Skip Navigation

[Resolved] How to shortcode quantitative data in a view?

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.

This topic contains 3 replies, has 2 voices.

Last updated by Beda 5 years, 5 months ago.

Assigned support staff: Beda.


I am trying to: Create shortcodes for expressing quantitative data in a simple pie chart using my charts.js i.e. ... No. of Views, media calls, parent posts, child posts or other stored values by user ID. I have a charts and graphs plugin and theme also provides optional charts.js. Just need to call specific data counts from from a shortcode to my frontend interface. Thanks.

I visited this URL:

I expected to see:

Instead, I got:


Charts can not be created with Views.

We also do not plan to include such a feature.

An additional Problem is, Views is not intended (and never was) to populate other Plugins' or Code values.

That Means, Views is designed to allow you to DISPLAY Data, and not pass it to a Custom Code or Plugin as variable DATA.

In this case we have plans to create a DATA providing Views but this has no ETA and Road map yet

Currently populating a value with a view will fail, because Views outputs are wrapped in a default HTML which will most definitely break your Custom Coded or Plugin's Chart.

You can use a Custom Filter to avoid this, and then create (carefully) JSON output with the Views, but this is definitely not supported or suggested by us.

You can see a approach here:

It is a very long thread, illustrating why we do not support this approaches.

View is a rendering engine, we can not change this.

But in above thread you will see a fully working approach.



Maybe I'm not making my application clear. So you're saying I can't pass quantitative values such as number of page views OR number of child post to a parent into a View or Content Template?

This is the type of data that's tracked with Google Analytics. I just want to use my charts.js to present charts in frontend as in a Control Panel dashboard overview for each user to see. Yes I have a charts plugin, but I don't need it to make this work. I'm using a javascript library to present the visual and need to write a shortcode to get and data as an analytics visual presentation "not the actual content", but figures.

Still a no go? Thanks.


You can DISPLAY this information.

Views, does wrap everything what you output in the Views Loop, in a default, native, HTML wrapper.
This was explained in the Ticket I posted above, along with the reasons why we do it, and how you can Customize the output at your own risk.

You can of course create a ShortCode with a Custom Function that displays or returns anything you want, as long it is available in your DataBase.

But Views, or Toolset ShortCodes, are here to display Data, or to be used in Conditional evaluations, but you will not be able to pass a entire View, to populate values of other applications.
(not as long you use the native and intended way of using Views)

Creating ShortCodes is not covered by our Support.
This would require Customized Code and Application approaches, which are not using the Toolset API and are not natively integrated in Toolset.

You might, if you need help with this, contact a certified partner to receive the help with the Custom Code you would need.
At this point I would suggest you consider contacting one of our certified partners from this link:

You will get the custom assistance you need to get on with your project.

Let me know if I can help you further with Toolset related issues or doubts.