Custom Rewrite with Query vars


I have been stuck on this for hours and tried all these different methods but none seem to work. I’ve seen other threads with a similar problem but the solutions are not working for me. I’m hoping someone can help.

I have a page with a custom template using the permalink

This page accepts query variables eg :

I’m trying to get a custom rewrite rule to work so that when people type in

it will display what


currently in my template functions.php I have

function add_query_vars_filter( $vars ){
  $vars[] = "information";
  return $vars;
add_filter( 'query_vars', 'add_query_vars_filter' );

function custom_rewrite_tag() {
  add_rewrite_tag('%information%', '([^&]+)');
add_action('init', 'custom_rewrite_tag', 10, 0);

function custom_rewrite()
add_action('init', 'custom_rewrite');

When I visit 

I only get taken to

My second issue is that p=64476 is hard coded, how do I get the id from $matches[1] ?

Ch3n 2 years 2020-12-24T06:10:23-05:00 0 Answers 4 views 0

Leave an answer