Display All Top Child Categories / Taxonomy

maybe you have to use this $categories=get_categories( array( ‘parent’ => $cat->cat_ID ) ); Then, in a loop, display this array because you can’t do it with an echo foreach ($categories as $c) { var_dump($c); // what you really want instead of var_dump is something to // to create markup– list items maybe, For example… echo … Read more

add action for wordpress query at a specific position

Yes, absolutely, it is possible. And here’s an example: Use an action and pass the post’s position in the loop to the action’s callback/function, and let the callback run the conditional and display the image if applicable. $position = 1; // start at 1 while ( have_posts() ) : the_post(); the_title( ‘<h3>’, ‘</h3>’ ); // … Read more

Exclude parent categories from recent posts list

I was able to find a function that worked found here. First, I added the below code to my functions.php, which excludes the parent categories I do not want: function custom_get_the_category_list() { $categories = get_the_category(); $exclude1 = get_cat_ID( ‘Parent1’ ); $exclude2 = get_cat_ID( ‘Parent2’ ); $categories_list=””; foreach ( $categories as $category ) { if ( … Read more

WP Query with meta queries

You have to use “orderby” => “meta_value_num” and set a “meta_query” at the same time. Then choose the “meta_key” you want to order by. Try: $query = new WP_Query( array( ‘post_type’ => ‘some_cpt’, ‘posts_per_page’ => – 1, ‘meta_query’ => array( array( ‘key’ => ‘active’, ‘value’ => ‘1’, ‘compare’ => ‘=’, ) ), ‘meta_key’ => ‘ranking’, … Read more