Displaying custom posts in categories

To retrieve all the terms attached to your taxonomy “brochure_categories”, you can use get_terms() function. More info here. Once you’ve got your terms, you can traverse them and query your custom posts with: $query = new WP_Query( array( ‘post_type’ => ‘brochures’, ‘brochure_categories’ => $current_category, ‘posts_per_page’ => -1, ‘order’ => ‘ASC’, ‘orderby’ => ‘title’, ) ); … Read more

How to keep a CPT stick to specific position?

If you index $related_posts by position along with $ad_posts, you can probably splice/insert them in at the same position… eg. function wpse_210493_apply_advertising_position(&$posts, $return = false) { $ad_posts = array(); $content_posts = array(); $related_post = array(); // Seperate $posts into “Ads” and “Content” arrays based on whether or not they have ‘rw_adversiting_position’ meta-data foreach ($posts as … Read more

How can I generate a list of post-type specific categories?

You can create a template page and use the WP loop: taxonomy-{taxonomy}-{term}.php https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/ Or you can use the get_posts functionality: https://codex.wordpress.org/Template_Tags/get_posts#Taxonomy_Parameters Something like this maybe: <?php $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘reports’, ‘my_custom_taxonomy_name’ => ‘education’, ‘post_status’ => ‘publish’ ); $show_albums = get_posts( $args ); ?> This will return a list of posts … Read more