Skip Navigation

[Resolved] The short-code for the current page url

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 9 months, 1 week ago.

Assisted by: Waqar.

Author
Posts
#2641967

Tell us what you are trying to do?
I have this in the template of my custum post page:
<h3>Cite this Essay:</h3>
<div class="cite-this">[types field='cite-name'][/types]. <span>“[wpv-post-title]”</span>, <span style="font-style:italic;">Electronic Book Review</span>, [types field="publicationdate" style="text" format="F j, Y"][/types], [types field='doi-ref'][/types].</div>

The last part [types field='doi-ref'][/types] is for a "doi-ref" field I set up to enter a reference url in each post (DOI). But sometimes there is no doi set in a post, which leaves this part of the concatenation blank and ending in ,.

I would like there to be a conditional - if there is no value in the doi-ref field, then enter the current post's url. I don't know the shortcode for the current posts url nor how to set a conditional.

Is there any documentation that you are following?
Trying!

Is there a similar example that we can see?

What is the link to your site?

#2642047

Hi,

Thank you for contacting us and I'd be happy to assist.

To conditionally display the field's value when it is not empty and show the current page/post URL, when the field is empty, you can replace:


[types field='doi-ref'][/types]

With:


[wpv-conditional if="( empty($(wpcf-doi-ref)) )"][wpv-post-url][/wpv-conditional]
[wpv-conditional if="( NOT(empty($(wpcf-doi-ref))) )"][types field='doi-ref'][/types][/wpv-conditional]

Useful documentation links:

https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-url

I hope this helps and please let me know if you need further assistance.

regards,
Waqar

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