Navigation überspringen

[Gelöst] How to calculate results in Views?

This support ticket is created vor 4 Jahre, 9 Monaten. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Zeitzone des Unterstützers: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Luo Yang vor 4 Jahre, 9 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#1792481

Tell us what you are trying to do?
I want to calculate the average of the last 5 results shown in Views.

The table is in this format:

<table>
  // Table head is hard coded into the View loop editor 
  <thead>
    <tr>
      <th>Year</th>
      <th>Sales</th>
    </tr>
  </thead>
  // For the year I use category to label the year
  <tbody>
  <tr>
    <td>2016 ([wpv-post-taxonomy type="category" format="name"])</td>
    <td>100 ([types field='sales'][/types])</td>
  </tr>
  <tr>
    <td>2017</td>
    <td>120</td>
  </tr>
  <tr>
    <td>2018</td>
    <td>80</td>
  </tr>
  </tbody>
</table>

Screenshot: versteckter Link

Is this possible with Views?

#1792645

Hello,

Unfortunately, there isn't such kind of built-in feature within Toolset plugins, the Toolset Views/Blocks plugin only display the results from database, it does not do the calculation.

You might consider custom codes, see WP document:
https://developer.wordpress.org/reference/functions/add_shortcode/