Lars Mertens Lars Mertens - 5 months ago 25
PHP Question

Using custom wordpress url link parameter instead of GET value in url

I will keep this very short.

I've read some tutorials about changing the following url for Wordpress:




So I can get clean links for search engines. And the page loads like its just reading the values of the
but with an easier to read url.

With the following code I tried to achieve my goal:


* For rewriting URLS on werkvorm

add_action('init', function(){

* Retrieve the data from the get parameter for werkvorm page

add_filter('query_vars', function( $vars ){
$vars[] = 'werkvorm';
$vars[] = 'item';
return $vars;

On the werkvorm page i can use:

$test = get_query_var( 'item' ); // to retrieve the data

Now when I use the url:

I'm getting a 404. However when I use
it works fine only the url is not changed. Any help on this is appreciated.


Change the Permalink Structure to 'Post Name' in admin->settings->permalinks.

Depending on your URL structure requirements, you may have to write some code. But the post name structure setting will do the trick here.