How to retrieve posts from parent category, splitting them per children when displayed?

Calling WP_Query three times isn’t too good for performance, as it will make three queries to the database. The way you’re currently approaching this seems like the proper (and fastest) way in may opinion. However, you should be calling $category_posts->rewind_posts() after each while-loop to reset WP_Query‘s loop to the first post. Furthermore, your current way … Read more

loop mix my child-category and parent-category

For the example you posted, the article is styled according to the css rule(s) for category-selling-and-advertising which is defined last (among the category-* classes) in the article’s class attribute. You need to intercept the functionality of post_class() to change the order these classes appear. The post_class filter will do the job for you: add_filter( ‘post_class’, … Read more

how to list subpages in sidebar without widget

Simplest solution would be: <li><ul> <?php wp_list_pages(‘title_li=&child_of=”.$post->ID.”‘); ?> </ul></li> Use this code for more flexibility: <?php if ( is_page() ) { ?> <?php if($post->post_parent) $children = wp_list_pages(‘title_li=&child_of=”.$post->post_parent.”&echo=0’); else $children = wp_list_pages(‘title_li=&child_of=”.$post->ID.”&echo=0’); if ($children) { ?> <li> <h2> <?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?> </h2> <ul> <?php echo $children; ?> </ul> </li> <?php } } … Read more