Display list of Sub-Categories and the posts they contain, within one main Category

Question was answered on another site.. thank you! BTW, the code that accomplished what I needed was: $categories = get_categories(‘child_of=31’); foreach ($categories as $category) { //Display the sub category information using $category values like $category->cat_name echo ‘<h2>’.$category->name.'</h2>’; echo ‘<ul>’; foreach (get_posts(‘cat=”.$category->term_id) as $post) { setup_postdata( $post ); echo “<li><a href=”‘.get_permalink($post->ID).'”>’.get_the_title().'</a></li>’; } echo ‘</ul>’; }

Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?

I’m posting my comment to @MarkKaplun as part of my answer. My point is this, every end user experience a certain thing in a certain way based on his/her own knowledge, experience, usability and personal preference. There can never be a wrong or right answer here. Option one might suite you best, option two might … Read more

Custom comment status possible?

Quick answer: no. There is not a built-in function to create a new comment status. The status of a comment (or a post/page/attachment/etc) contains wide-spread implications thoughout your WordPress install, so you couldn’t just add one somewhere quickly. I’m not exactly sure what you’re trying to accomplish by adding this new “status”, but I think … Read more

How do I make wp_get_archives show me months where only pages were created?

The wp_get_archives() function runs a filter on its WHERE clause–it’s called getarchives_where. You could use this to modify the query to only include pages rather than posts (which is the hard-coded default). I haven’t tested this yet, but try it out: add_filter(‘getarchives_where’,’my_archives_filter’); function my_archives_filter($where_clause) { return “WHERE post_type=”page” AND post_status=”publish””; } Then, just use the … Read more

Optimal way to redirect home page to category archive?

Eliminating all of the other solutions, there is at least one remaining: template_redirect: function wpse121308_redirect_homepage() { // Check for blog posts index // NOT site front page, // which would be is_front_page() if ( is_home() ) { wp_redirect( get_category_link( $id ) ); exit(); } } add_action( ‘template_redirect’, ‘wpse121308_redirect_homepage’ ); You will need to pass the … Read more

Date archives for custom post type

What you want can be done also filtering ‘month_link’ for monthly archives, ‘year_link’ for yearly archives and ‘day_link’ for daily archives. You can also write a function that extends wp_get_archives to work with CPTs, adding filters to ‘getarchives_where’ and to the archive link. function wp_get_cpt_archives( $cpt=”post”, $args = array() ) { // if cpt is … Read more

How to hide a specific category posts in my monthly archive?

There are two ways of doing it: You can use a filter to alter the query when viewing an archive page. You will need to find the ID of your category ‘blogs’ (you can obtain it from the slug using get_term_by). Alternatively you can exclude a particular category by ID. add_action( ‘pre_get_posts’, ‘my_change_query’); function my_change_query($query){ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)