Saltar navegación

[Resuelto] 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 -

Zona horaria del colaborador: Asia/Kolkata (GMT+05:30)

Este tema contiene 1 respuesta, tiene 1 mensaje.

Última actualización por Saul Baizman 1 year, 4 months ago.

Asistido por: Minesh.

Autor
Mensajes
#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:

enlace oculto

We'd like the URL to look like this:

enlace oculto

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
Colaborador

Idiomas: Inglés (English )

Zona horaria: 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!