Get posts in same category not working

This should work for a custom taxonomy. <?php function get_related_posts() { global $post; $taxonomy = ‘your_custom_taxonomy’; $terms = wp_get_post_terms( $post->ID, $taxonomy ); if($terms) { $term_arr=””; foreach( $terms as $term ) { $term_arr .= $term->slug . ‘,’; // create array of term slugs } $args = array( ‘showposts’ => 5, // you can change this to … Read more

WP_Query with custom post type search showing all results every time

It doesn’t look like you’re passing your search query in your WP_Query args. To do this on a custom search page try the following: Replace this: $the_query = new WP_Query(‘post_type=darpe-entries’); With this: global $query_string; $query_args = explode(“&”, $query_string); $search_query = array(); foreach($query_args as $key => $string) { $query_split = explode(“=”, $string); $search_query[$query_split[0]] = urldecode($query_split[1]); } … Read more

Display Custom taxonomy, Child terms and posts in a template Under Specific Parent terms

This is the working code. You can try with yours $id = get_the_ID(false); $categories = get_the_category(); $parents = array(); $childs = array(); foreach($categories as $cat){ if($cat->parent == 0){ $parents[] = $cat; } else { $childs[] = $cat; } } $i = 1; echo “<div class=”sub-container”>”; foreach($parents as $parent){ if($i>3){ $i=1; echo “<div class=”clr”></div>”; echo “<hr … Read more