Custom post type and custom taxonomy 404 on page 2

So after many trials and errors, I found I had to create a specific rewrite rule to go into my functions.php, one that handles post type ‘videos‘ and the category (taxonomy) ‘videos_category‘: add_filter(‘init’, function() { add_rewrite_rule( ‘^videos/([^/]*)/([^/]*)/(\d*)?’, ‘index.php?videos_category=$matches[1]&p=$matches[2]&paged=$matches[3]’, ‘top’ ); }); I also found this plugin to be really helpful for viewing my rewrite rules: …

Read more

How to query for posts (hierarchical custom post type) that have children but are NOT top level?

You can use filters to modify the SQL. I added something unique in the post_type so I could filter only this query and not change anything else. The query for example $query = new WP_Query(array(‘post_type’=>’something_unique_for_filter’)); And the filter function custom_where($where, $query) { global $wpdb; if(false !== strpos($where, ‘something_unique_for_filter’)) { $where = ” AND post_type=”page” AND …

Read more

Archive Page for Multiple Custom Post Types

Let’s say you have custom post types cpt_a, cpt_b, cpt_c. You could make an archive page for cpt_a: archive-cpt_a.php. Then after the main loop, you could make a second loop for cpt_b like this: $cpt_b = new WP_Query( array( ‘post_type’ => ‘cpt_b’, ‘posts_per_page’ => -1 ) ); while ( $cpt_b->have_posts() ) : $cpt_b->the_post(); the_title(); endwhile; …

Read more

WordPress rewrite url

But we are not limited to default formats, as WordPress allows users to customize the pretty permalink format by setting one or more structure tags. The custom structure option allows to set a highly customized pretty permalink format The custom structure option allows to set a highly customized pretty permalink format