This is my Custom Post Type "newyork":
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'newyork',
array(
'labels' => array(
'name' => __( 'New York' ),
'singular_name' => __( 'New York' )),
'public' => true,
'has_archive' => true,
'query_var' => true,
'supports' => array( 'title', 'editor', 'revisions', 'thumbnail',),
'rewrite' => array('slug' => 'newyork')
)
);
}
For this i've created an archive-page called "archive-newyork.php" with the "standard" loop:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post">
<h3><?php the_title(); ?></h3>
</div><!-- .post -->
<?php endwhile; ?>
<?php endif; ?>
<div id="pagination">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi();}
else { ?>
<?php previous_posts_link(__('<div id="left">vorherige Seite</div>')) ?><?php next_posts_link(__('<div id="right">nächste Seite</div>')) ?>
<?php } ?>
</div>
<?php wp_reset_query(); ?>
On top of that page i've got a dropdown to filter posts by month:
<select name="archive-dropdown" class="orderby" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""><?php _e( 'Bitte den gewünschten Monat auswählen', 'baumwollboerse' ); ?></option>
<?php add_filter( 'get_archives_link', 'get_archives_events_link', 10, 2 );
wp_get_archives( array( 'post_type' => 'newyork', 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1 ) );
remove_filter( 'get_archives_link', 'get_archives_events_link', 10, 2 ); ?>
</select>
This works good so far but when i filter, for example, by the month "september 2014" it gives me the 10 posts (as defined on the WP settings page) as expected. …but when i click on "next posts" the page "/newyork/2014/09/page/2/" jumps autpmatically to the first post ever created from that custom post type...
This problem only appears on the filtered month-page. It works perfectly on the unfiltered archive page...
I already "flushed" the rewrite rules by saving/visiting the permalinks page multiple times with no luck!
Any ideas?
Thanks in advance... Jochen
Aucun commentaire:
Enregistrer un commentaire