Skip Navigation

[Resolved] Rewriting urls to remove query string syntax

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 1 reply, has 1 voice.

Last updated by Saul Baizman 5 days, 18 hours ago.

Assisted by: Minesh.

Author
Posts
#2795355

Hi there,

We've created a page which houses a view. The view is passed a URL parameter via a query string like so:

hidden link

We'd like the URL to look like this:

hidden link

Is that possible via custom PHP code? Can I add a custom rewrite rule? I attempted to add a rewrite rule (below), but it didn't work:

add_action ( 'init', callback: , 'add_rewrite_rules', priority: 10, accepted_args: 0 ) ;
function add_rewrite_rules ()
{
	add_rewrite_rule('^(inside-out-archive-experiment)/([0-9]{4})/?$', 'index.php?pagename=$matches[1]&prog-year=$matches[2]','top');
}
add_filter ( 'query_vars', 'add_query_vars' );
function add_query_vars ($vars)
{
	$vars[] = 'prog-year';
	return $vars;
}

Thank you.

Saul

#2795375

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

View's URL param are required to filter views correctly as well as for pagination hence there is no such feature to rewrite the view's URL param.

#2795444

OK, thanks, Minesh!