I need to pass a property reference the last part of a URL to search the database for an entry, eg,
I need to pass the G638 into an array for my plugin. What I have below is calling the cottage-details page, but removing the last part of the URL and showing an empty page, rather than the information I wish to retrieve from the server. If I use
it works perfectly.
/**
* Rewrite tags for plugin
*/
function dcc_rewrite_tags() {
add_rewrite_tag('%propref%', '([^&]+)');
}
add_action('init', 'dcc_rewrite_tags', 10, 0);
/**
* Rewrite rules for plugin
*/
function dcc_rewrite_rules() {
add_rewrite_rule('^[^/]*/([^/]*)/?','index.php?p=2&propref=$matches[1]','top');
}
add_action('init', 'dcc_rewrite_rules', 10, 0);
What’s going on?