Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
Created April 14, 2015 23:35
Show Gist options
  • Save LinzardMac/d4bcdef8a0e0371af52a to your computer and use it in GitHub Desktop.
Save LinzardMac/d4bcdef8a0e0371af52a to your computer and use it in GitHub Desktop.
How to add query variables to WP URL
// create your variable, add your "key" called event_event, and define what the value should be
//for front end
$edit_post = add_query_arg( 'edit_event', $user_post->ID, site_url('/edit-events/') );
//for admin
$edit_post = add_query_arg( 'edit_event', $user_post->ID, admin_url('admin.php?page=example') );
// then simply do this for your link
<a href="<?php echo $edit_post; ?>" title="edit event"><?php echo $user_post->post_title; ?></a>
// then get the value to create whatever query you want
$passed_id = $_GET['edit_event']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment