Passer la navigation

[Résolu] Rewriting urls to remove query string syntax

This support ticket is created Il y a 1 year, 4 months. 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.

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 -

Fuseau horaire du supporter : Asia/Kolkata (GMT+05:30)

Ce sujet contient 1 reply, a 1 voix.

Dernière mise à jour par Saul Baizman Il y a 1 year, 4 months.

Assisté par: Minesh.

Auteur
Publications
#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:

lien caché

We'd like the URL to look like this:

lien caché

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

Les langues: Anglais (English )

Fuseau horaire: 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!