I'm trying to add a rewrite rule to make this:
mysite/?attachment_id=106
look like this:
mysite/series/106
I've looked everywhere in this site and others and it's very confusing because there are lots of different ways to do it.
I've tried editing the functions.php
file in my themes folder, adding this at the beginning of the file:
add_rewrite_rule('series/([^/]+)/?$', 'index.php?attachment_id=$matches[1]', 'top');
And the latest one I've tried:
add_filter( 'query_vars', 'wpa56345_query_vars' );
function wpa56345_query_vars( $query_vars ){
$query_vars[] = 'attachment_id';
return $query_vars;
}
add_action( 'init', 'wpa56345_rewrites' );
function wpa56345_rewrites(){
add_rewrite_rule(
'series/(\d+)/?$',
'index.php?attachment_id=$matches[1]',
'top'
);
}