I am using Divi and WordPress most recent versions.
I would like to sum the values of an single field in a View loop targeting a custom post type (Ingredients) that are filtered to display the cpt posts that are related to the WordPress Post in which the View is shown.
I've attempted to register the two custom plug-ins displayed in this KB article: hidden link
I registered them as two separate plugins in Toolset Settings, one with the slug "add-to-total" (.php) and one with "show-total" (.php). I have not registered these in functions.php. I attempted that to see if that was potentially the problem and got a parsing error.
Here is my code in the view:
<!-- wpv-loop-start -->
<wpv-loop>
[types field="carbohydrates-ing" output="raw"][/types]
[add-to-total]
[types field="carbohydrates-ing" output="raw"][/types]
[/add-to-total]
</wpv-loop>
<!-- wpv-loop-end -->
[show-total]
When I display the View front-end I get the following output:
7 [add-to-total] 7 [/add-to-total] 6 [add-to-total] 6 [/add-to-total] 0.0 [add-to-total] 0.0 [/add-to-total] 3.7 [add-to-total] 3.7 [/add-to-total] 63 [add-to-total] 63 [/add-to-total] [show-total]
As you can see, the View is displaying the values of the fields in the filtered view but the shortcodes that sum the fields and display the total do not appear to be functioning.
Hello. Thank you for contacting the Toolset support.
Can you please share problem URL where you added the view and access details so I can check what going wrong there.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Doh! I had a Homer Simpson moment.
I had not activated the Plugins in Toolset Settings. I am now correctly displaying each value of the field for each related post and it the plug-in is correctly displaying the product of the five values. Here is how that View displays in the Post:
7 6 0.0 3.7 63 79.7
I note that 79.7 is the total of the five fields displayed.
I merely want to display the Total (i.e. the 79.7). How do I target the result of the "show-total" plug-in only on the front-end in the Post?
The page to view front-end is: hidden link
You will see the View displayed bottom-left in a single white line below the far-left image of the four displayed images.
Can you please remove the [types field="carbohydrates-ing" output="raw"][/types] shortcode from your code that is added just before the [add-to-total] shortcode and save your view and check.
Upps. I need to check then. Can you please share access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Can you please check now. As I said in my previous reply I deleted this shortcode: [types field="carbohydrates-ing" output="raw"][/types]
As you can see with your view now:
=> hidden link
Minesh: Thanks a million. I had removed the other occurrence of that field, not the one BEFORE the shortcode. My apologies.
Looks great. I'll send you post card from the French Riviera once I'm a millionaire. 🙂