WordPress Child Category Display All Posts

One of the arguments you can supply to get_posts is posts_per_page. If you don’t include this, then it will default to your Pages Show at Most setting on the Reading page of your settings. http://wordpress.org/support/topic/get_posts-not-pull-all-posts-unless-numberposts-in-query. Yes, I know the forum thread is 2 years old, but it confirms the suspicion that I had after reading … Read more

Showing current subcategory

I have a suspicion that you’ve fallen into a misunderstanding a lot of new users fall into, but rarely realise. I suspect you have done this: This is bad, and suggests a lack of understanding about how categories work. It will also cause issues in your code when your assumptions don’t match the reality of … Read more

List post from current taxonomy children

I had an idea of combining the first code with this solution that lists posts from a specifik taxomony: <?php $terms = get_terms(‘productcategories’); foreach ($terms as $term) { $wpq = array ( ‘taxonomy’=>’productcategories’, ‘term’=>$term->slug, ‘order’=>’asc’, ‘orderby’=>’title’); $query = new WP_Query ($wpq); echo “$term->name:<br />”; ?> <?php if ($query->have_posts() ) : while ($query->have_posts() ) : $query->the_post(); … Read more

How to get the excerpts of all children pages

Firstly, it should be post_excerpt. Secondly, this just stores the manually added excerpt, so it returns empty if you don’t have one. Thirdly, you could setup_postdata: <?php $pagechildren = get_pages( array( ‘child_of’ => $post->ID ) ); ?> <?php foreach ( $pagechildren as $post ) : setup_postdata( $post ); ?> // code <?php endforeach; wp_reset_postdata(); ?> … Read more

How can I make wp_list_categories output li with category-slug as class, for its children?

I am not sure if querying the categories again is the good idea. The following code extends the Walker_Category and makes use of it to do the replacement. Put the following in your functions.php: class WPSE67791_Walker_Category extends Walker_Category { public function start_el(&$output, $category, $depth, $args) { parent::start_el( $output, $category, $depth, $args ); $find = ‘cat-item-‘ … Read more

Get threaded comments number

// inside your callback function: static $ancestors = null; $parent = (int) $comment->comment_parent; // Modify INITIAL VALUE here: $init_val = (int) 1; $is_child = false; if ( $parent > (int) 0 ) { $is_child = true; $ancestors[] = $parent; $child_counter = count( $ancestors ) + $init_val; } /* * Only needed in case you want … Read more

Show children of top level category only

Ok, try this. It should capture the current category object and then go up the chain until it finds the current categories top-most ancestor. // get the category object for the current category $thisCat = get_category( get_query_var( ‘cat’ ) ); // if not top-level, track it up the chain to find its ancestor while ( … Read more

Only allow new subpages to be created

Code based in Bainternet’s answer to this question: Make Categories and Tags required in admin See code comments. add_action( ‘admin_head-post-new.php’, ‘wpse_59770_publish_admin_hook’ ); add_action( ‘admin_head-post.php’, ‘wpse_59770_publish_admin_hook’ ); add_action( ‘wp_ajax_wpse_59770_pre_submit_validation’, ‘wpse_59770_ajax_pre_submit_validation’ ); function wpse_59770_publish_admin_hook() { global $current_screen; if( ‘page’ != $current_screen->post_type ) return; ?> <script language=”javascript” type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#publish’).click(function() { var form_data = jQuery(‘#parent_id’).val(); form_data = … Read more

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