How to display only sticky posts on category pages?

You can try to fetch the sticky posts IDs from the sticky_posts option and then modify the main query on the category archives accordingly: /** * Category Archives: Only display sticky posts for each category term */ add_action( ‘pre_get_posts’, function( \WP_Query $q ) { if( ! is_admin() && $q->is_category() && $q->is_main_query() ) { $sticky_posts = … Read more

Getting a sub category based on a category name

If you want to get all the descendents for the volume category and its ID is lets say 5: $categories = get_categories( array( ‘child_of’ => 5 )); foreach($categories as $category) { echo ‘<p>Category: <a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $category->name ) . ‘” … Read more

Split posts into 2 separate streams

Assuming the following You are using WP default Post type When you say tagged you mean you used categories and not the tag system You have at least the following categories 2015 and 2016, and that you have categorized all of your posts accordingly You are using the default blogroll of WP If I assumed … Read more

How to modify list categories code?

I’m now using the following code which allows me to format the list as required: <?php if (is_category( )) { $thiscat = get_category( get_query_var( ‘cat’ ) ); $catid = $thiscat->cat_ID; $parent = $thiscat->category_parent; if (!empty ($parent) ) { //child category pages $catlist = get_categories( array( ‘child_of’ => $parent, ‘orderby’ => ‘id’, ‘order’ => ‘DESC’, ‘exclude’ … Read more

Display only children of custom hierachial taxonomy

Based on our comment discussion, you’re using the code in a sidebar widget (that accepts php code) on a single post page. It ended up being much more complex than expected. This should work though. <?php $taxonomy = ‘download_category’; $terms = wp_get_object_terms( get_the_ID(), $taxonomy ); $parents = array(); // Loop through all album categories. foreach … Read more