WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
Jacob’s comment got me on the right track. Here’s what worked for my issue: add_action(‘init’, ‘cpt_rewrite’); function cpt_rewrite(){ $args = array( ‘public’ => true, ‘_builtin’ => false, ); $post_types = get_post_types( $args ); if ( $post_types ) { foreach ( $post_types as $post_type ) { add_rewrite_rule(‘^’.$post_type.’/([0-9]{4})/([0-9]{2})/?’,’index.php?post_type=”.$post_type.”&year=$matches[1]&monthnum=$matches[2]’,’top’); add_rewrite_rule(‘^’.$post_type.’/([0-9]{4})/?’,’index.php?post_type=”.$post_type.”&year=$matches[1]’,’top’); } } } I used get_post_types() to get … Read more
Can’t add custom post type archive page to menu
Add custom display condition to Elementor Theme Builder for custom taxonomy children, grandchildren, and great-grandchildren
You can have a different slug for the archive by setting has_archive to a string: register_post_type( ‘whatever’, array( ‘has_archive’ => ‘whatever/results’, ‘rewrite’ => array( ‘slug’ => ‘whatever’, ), // …etc. ) ); I’ve tested that and it seems to do exactly what you needed.
Put this code <div class=”row”> <div class=”col-md-8 col-md-offset-2″> <?php $args = array( ‘posts_per_page’ => 3, ‘post_type’ => ‘work’, ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1 ); $myposts = new WP_Query($args); ?> <?php single_term_title(); ?> <?php if ( $myposts->have_posts() ) : ?> <?php while ( $myposts->have_posts() ) : $myposts->the_post(); ?> <?php get_template_part( ‘content’, get_post_format() );?> <?php … Read more
Best practice to display a list/archive of Custom Posts in a Page Template
Pagination not working on custom post type archive
add_rewrite_rule pagination 404 error on page 4 and above
This is going to be dependent upon how you created the custom post type. If you actually just created a post type called book and didn’t create any rewrites then all you have to do is link to /book. There’s nothing amateur about doing it this way…that’s how WordPress is designed. The only thing I … Read more