Display Sub-categories or Child Pages of Parent Cat/Page?

for sub-pages of current page check wp_list_pages() <?php $page_id = get_the_ID(); wp_list_pages( array( ‘child_of’=>$page_id ) ); ?> and for sub-categories of the parent category check wp_list_categories() <?php $cat_id = get_query_var(‘cat’); if( !empty($cat_id) ) { wp_list_categories( array( ‘child_of’=> $cat_id ) ); } ?>

List post only under the category, exclude child category content

to solve this you can create a page template, on this page template 1.get the top level categories only, set parent value to zero $args = array( ‘orderby’ => ‘name’, ‘parent’ => 0 ); $categories = get_categories( $args ); 2.get posts in all parent categories foreach ( $categories as $category ) { $all_posts=get_post(‘category=’.$category->term_id); foreach( $myposts … Read more

Display post thumbnail for specific category outside the loop

Use get_the_post_thumbnail with a new WP_Query. <?php if ( has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ‘large’); echo ‘<a href=”‘ . $large_image_url[0] . ‘” title=”‘ . the_title_attribute(‘echo=0’) . ‘” >’; echo get_the_post_thumbnail($post->ID, ‘thumbnail’, array(‘class’ => ‘aligncentre’)); echo ‘</a>’; } ?>

Problem with Custom Post Type Categories

If the Categories referred to here are the WordPress native category taxonomy, the queries for these term pages by default will only include the native post post type. To add custom post types to category term queries, you can add a bit of code to your theme’s functions.php file, which modifies these queries via the … Read more