Get post by Category in custom template

<?php $categories=get_categories(”); foreach($categories as $category) { echo ‘<p>Category: <a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $category->name ) . ‘” ‘ . ‘>’ . $category->name.'</a> </p> ‘; echo ‘<p> Cat ID: ‘. $category->cat_ID. ‘</p>’; // The Query $id_cat = $category->cat_ID; $args = array( ‘cat’ => … Read more

Sidebar Categories change arrow when subcategories are shown on click

I added these lines: $(this).removeClass(‘ic-arrdn’).addClass(‘ic-arrup’); $(this).removeClass(‘ic-arrdn’).addClass(‘ic-arrup’); and achieved the result. $(document).ready(function () { $(“aside ul li:has(ul)”).addClass(“ic-arrdn”); var e = $(“aside > ul > li.current-cat, aside > ul > li.current-cat-parent”); if (e.length == 1) { } $(“aside > ul > li > ul.children”).each(function () { $(this).find(“li”) $(this).parent().toggle(function () { $(this).find(“ul”).slideDown(); $(this).removeClass(‘ic-arrdn’).addClass(‘ic-arrup’); }, function () { $(this).find(“ul”).slideUp(); … Read more

exclude parents from the_terms

use get_the_terms instead and exclude any terms where parent value is 0, which means it is a top-level term. $terms = get_the_terms( $post->ID, ‘portfolio-type’ ); if ( !empty( $terms ) ) { $output = array(); foreach ( $terms as $term ){ if( 0 != $term->parent ) $output[] = ‘<a href=”‘ . get_term_link( $term ) .'”>’ … Read more

(WordPress) How to get custom taxonomy parent name?

Using two nested foreach you prevent n+1 db queries, where n is the number of child terms: <?php $_cats = array(); $args = array( ‘orderby’ => ‘id’, ‘order’ => ‘ASC’, ‘taxonomy’ => ‘album’ ); $categories = get_categories($args); if ( ! empty($categories) ) { foreach( $categories as $category ) { if ( $category->parent != 0 ) … Read more

display certain category on custom template page

You should not use category parameter to query custom taxonomy instead you should use tax_query parameter or directly custom taxonomy name as shown in the following query. query_posts( array( ‘post_type’ => ‘ublalfieportfolio’, ‘ublalfieportfolio-categories’ => ‘parketten’, ‘posts_per_page’ => -1) ); Refer this page to know how to use custom taxonomy parameter in custom query.