get_the_category listing in hierarchial order

Use wp_list_categories instead, <?php $args = array( ‘hierarchical’ => true, ‘child_of’ => 42, //parent category ‘hide_empty’ => 1, //hide empty categories (set to 0 to show) ); wp_list_categories($args); ?> A full list of parameters for wp_list_categories can be found HERE As you can see its highly customizable simply by adding extra arguements to the array … Read more

Trying to alter the post_content through the_post

It seems you’re actually looking for the the_content filter. add_filter(‘the_content’, ‘modify_content’); function modify_content($content) { global $post; if ($post->ID != $desired_id) return $content; $modified_content = /* modify content here */; return $modified_content; }

how can i change WP main archives loop to sort by name or title

Use pre_get_posts to do any alterations of the main query. The main query happens before the template is loaded, using query_posts just overwrites that original query, which is a waste of resources: function wpa82795_archives_orderby( $query ) { if ( $query->is_archive() && $query->is_main_query() ) { $query->set( ‘orderby’, ‘title’ ); $query->set( ‘order’, ‘asc’ ); } } add_action( … Read more

How to get date of post when using wp_get_recent_posts()?

You can see everything returned via php’s var_dump or print_r: $recent_posts = wp_get_recent_posts(); echo ‘<pre>’; print_r( $recent_posts ); echo ‘</pre>’; This will reveal that the date is stored in post_date: foreach( $recent_posts as $recent ): echo $recent[‘post_date’]; endforeach; Or to format the date, use php’s date and strtotime: echo date( ‘l F jS’, strtotime( $recent[‘post_date’] … Read more

How to order posts in an arbitrary order?

First off, query_posts is terrible doesn’t use it. It does all kinds of fun things like mess up the very useful conditional tags like is_singular and the like as well as mess up pagination. Short of hooking into the posts_orderby filter and writing some custom order by SQL, your best bet is to use the … Read more