I'm trying to update my link from this: https://dev.brunchwork.com/next-event/?eb_event_id=106098978902 To this: https://dev.brunchwork.com/next-event/[guest_name_here]/[event_id_here]

Following this discussion, I was able to come up with this code:

In my functions.php:

/*rewrite rule*/
function custom_rewrite_rule() {

add_action('init', 'custom_rewrite_rule', 10, 0);

add_filter('query_vars', 'add_query_vars');
function add_query_vars($aVars) {
    $aVars[] = "guest_name";
    $aVars[] = "event_id";
    return $aVars;
/*end rewrite rule*/

In my next-event page:

Template Name: Single Event Template (updated)


global $wp_query;

$guest_name = $wp_query->query_vars['guest_name'];
$test_eb_event_id = $wp_query->query_vars['event_id'];

echo $guest_name;
echo $test_eb_event_id;

When I try to test the URL, the rewrite is not working. I also clicked the save button in the permalinks page to apply the changes.

So when I enter: https://dev.brunchwork.com/index.php?page_id=69&guest_name=test&event_id=123

I get https://dev.brunchwork.com/next-event/?guest_name=test&event_id=123

Any help is highly appreciated. Thank you very much!

1 Answer 1


There's nothing wrong with my code. Maybe it was not refreshed instantly so the changes did not propagate right away.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.