Alfredv
Alfredv

Reputation: 1

Sanatize title in url php

I'm trying to do a search based on the title.

Like this:

$alfred = get_the_title();
$link11 = "http://example.com/?s=$alfred";

The problem is:
When the title is

Account Manager (m/w) Software- / IT-Lösungen (non Microsoft)

it makes this url:

jobsde.de/?s=AccountManager%28m/w%29Software-/IT-L%C3%B6sungen%28nonMicrosoft%29

or when the title is

Recruiting Consultant (m/w)

it becomes jobsde.de/?s=RecruitingConsultant%28m/w%29

The wordpress search will not give me the results i want. I think there must be a way to handle this properly, but i don't know how. Any thoughts?

I found this

I now have:

$title = get_the_title();
sanitize_title_for_query( $title );
$link5 = "http://jobsde.de/?s=$title";

That doesnt work. The url still looks like:

jobsde.de/?s=HandelsvertreterPhotovoltaikSolarW%C3%A4rmepumpePhotovoltaikBeratersolarberater

What code should i use?

Upvotes: 0

Views: 116

Answers (1)

Cjmarkham
Cjmarkham

Reputation: 9681

Have a look at urldecode

This will return all encoded characters to their defaults

Upvotes: 1

Related Questions