Skip Navigation

[Resuelto] Issues with URL encoding

This support ticket is created hace 2 años, 9 meses. 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.

This topic contains 3 respuestas, has 2 mensajes.

Last updated by Craig hace 2 años, 9 meses.

Assigned support staff: Nigel.

Autor
Mensajes
#1418109

Hi there,
I am trying to troubleshoot an issue I am having with a URL which is being passed to another page which contains a contact form. The Loop I am using is below:-

<wpv-loop>
<div class="col-sm-4 staff-member search-results">
<a href='../contact-form/?emailto=[wpv-post-title]'>[wpv-post-featured-image size="custom" attr="class=image-size" width="156" height="208"]<br />[wpv-post-title output='raw']</a><br />[types field="position" id=""][/types]
</div>
</wpv-loop>

The issue is when the Post Title (which is a persons name) contains an apostrophe, the URL returns a 403 Error.

I have tried adding output='sanitize' or output='raw' to the shortcode, but neither work. Is there a way to allow apostrophes to work in the URL?

The URL where the issue currently is – hidden link
The person in question is Yvonne O’Hara, all other links work OK.

Hope you can help.

Kind regards,
Craig

#1418179

Nigel
Supporter

Languages: Inglés (English ) Español (Español )

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

You need to URL encode the title (which isn't an output option of the Views shortcodes), so you would likely need to create a custom shortcode for this.

You could create a specific shortcode to output the URL encoded title, or you could register a generic shortcode to encode whatever was within it, something like:

add_shortcode('urlencode', function ($atts = [], $content = null) {

    return urlencode( wpv_do_shortcode( $content ) );
});

which you could then use like:

[urlencode][wpv-post-title][/urlencode]
#1418187

Hi Nigel,

That is fabulous. Thank you so much for that.

Have a Merry Christmas!

Best regards,
Craig

#1418189

My issue is resolved now. Thank you!