Why get_posts() not returning only selected category posts from Custom Post Type?

First, your custom post type is portfolio-item, not portfolio_item. Note that you register the post type with $this->base name and previously you did $this->base=”portfolio-item”;. Also, numberposts is obsolete, use post_per_page instead: $args = array( // ‘post_type’ => ‘portfolio_item’, ‘post_type’ => ‘portfolio-item’, ‘orderby’ => ‘rand’, ‘post_per_page’ => 1 ); Then, the taxomy argument of your query … Read more

Create a hierarchical taxonomy list in WordPress

You can use wp_list_categories() and pass in your custom taxonomy as an argument like so: $args = array( ‘taxonomy’ => ‘locations’, ‘orderby’ => ‘name’, ‘hide_empty’ => false, ‘show_count’ => false, ‘pad_counts’ => false, ‘hierarchical’ => true, ‘title_li’ => ” ); ?> <ul> <?php wp_list_categories( $args ); ?> </ul> https://developer.wordpress.org/reference/functions/wp_list_categories/

List child terms if parent but show nothing on children

For reliability, you can get the current term being viewed from the queried object from $GLOBALS[‘wp_the_query’] $current_term = sanitize_term( $GLOBALS[‘wp_the_query’]->get_queried_object() ); To answer your question, if Southern Africa is top level, it should have a parent term ID of 0. All child terms should have a numeric value as parent which corresponds to the parent … Read more

What template files do I need to customise custom-category-term-links rather than fall back on archive.php?

Custom taxonomies have templates named taxonomy-something in this hierarchy: taxonomy-{taxonomy}-{term}.php taxonomy-{taxonomy}.php taxonomy.php archive.php index.php So, yes, if you have no taxonomy-custom-cat-term-cat.php, taxonomy-custom-cat.php or taxonomy.php then archive.php will be used. category-something.php will only be used for the built-in categories, if you are on a page showing posts from a category called “something.”