Hi everybody!
Here is my issue:
I have a Costum Post Type called Videogallery with an archive page showing all the videos with pagination and single post pages with the single videopost in the header and an archive (with pagination) of all the rest of the videos in the content.
The problem is that in the single page the next previus link doesn't work (gives me a link to: http://www.myhomepage.com/videogallery/post-title/page/2/ instead of the right link that should be I guess: http://www.myhomepage.com/?videogallery=post-name0&paged=2), while in the ?post_type=videogallery page works giving: http://localhost/RITM/page/2/?post_type=videogallery!
My permalinks structure is:
/%category%/%postname%/
My post_type rewrite arg is:
'rewrite' => array("slug" => "videogallery", 'with_front' => false)
My rewrite function is:
add_new_rules();
function add_new_rules(){
global $wp_rewrite;
$rewrite_rules = $wp_rewrite->generate_rewrite_rules('videogallery/');
$rewrite_rules['videogallery/?$'] = 'index.php?post_type=videogallery&paged=' . $wp_rewrite->preg_index(1);
foreach($rewrite_rules as $regex => $redirect)
{
if(strpos($redirect, 'attachment=') === false)
{
$redirect .= '&post_type=videogallery';
}
if(0 < preg_match_all('@\$([0-9])@', $redirect, $matches))
{
for($i = 0; $i < count($matches[0]); $i++)
{
$redirect = str_replace($matches[0][$i], '$matches['.$matches[1][$i].']', $redirect);
}
}
$wp_rewrite->add_rule($regex, $redirect, 'top');
}
}
any idea of what is wrong?
Thank you very much!