Pagination on custom post type not working

Fixed it by changing the page’s name (more so the page’s URL) so that it did not match the post type name, which causes rewrite problems.

I also learned that previous_posts_link(); and next_posts_link(); as well as wp_paginate() rely on the query variable being named “$wp_query”, so “$my_query” doesn’t work.

Here’s my fixed code:

if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) {$paged = get_query_var('page'); } else {$paged = 1; }

$args = array('post_type' => 'directory',
'posts_per_page' => 2,
'paged' => $paged
);

$wp_query = new WP_Query($args);

while ($wp_query->have_posts()) {
    $wp_query->the_post();
    // do stuff
}
previous_posts_link();
next_posts_link();