add_filter and add_action

What’s the difference between add_filter and add_action?
The difference is semantic. You can use add_filter() for an action, and you can use add_action() for a filter. The difference is there because actions and filters have a different code “mentality.” Filters are just that, filters through which information is passed, and then used. For example… the [...]

query_vars

query_vars
query_vars is a filter on the query variables used by the WP_Query class (and stored in $wp_request->public_query_vars).
The initial array consists of the following query variables:

m
p
posts
w
cat
withcomments
s
search
exact
sentence
debug
calendar
page
paged
more
tb
pb
author
order
orderby
year
monthnum
day
hour
minute
second
name
category_name
feed
author_name
static
pagename
page_id
error
comments_popup
attachment
attachment_id
subpost
subpost_id
preview

Your hook would accept an array, add an item to the array, and return the array.
function add_my_query_var($vars) {
$vars[] = ‘my_var’;
return $vars;
}

add_filter(‘query_vars’, ‘add_my_query_var’);