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>’; }

posts page – different lengths of excerpt

First, you need to filter excerpt_length. Assuming you want your default excerpt length to be 50 words: <?php function wpse53485_filter_excerpt_length( $length ) { return 50; } add_filter( ‘excerpt_length’, ‘wpse53485_filter_excerpt_length’ ); ?> That will make all excerpts 50 words. Make sure that works first. Then, add in an appropriate conditional, to use a different excerpt length … Read more

Endless loop with wp_insert_post and wp_update_post

It sure can be written in a more efficient way (untested): $added = array(); global $wpdb; foreach($uniques as $unique){ $pagetitle = getTitle($unique); $new_post = array( ‘post_title’ => $unique, ‘post_status’ => ‘publish’, ‘post_type’ => ‘websites’ ); $pid = wp_insert_post($new_post); if ($pid) { $wpdb->query( $wpdb->prepare( “INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, ‘%s’, ‘%s’), (%d, ‘%s’, … Read more

WooCommerce Product Page Loop – Output All Product Thumbnails

The second parameter on get_the_post_thumbnail takes the size of the image you want. You’re currently passing in: apply_filters( ‘single_product_large_thumbnail_size’, ‘shop_single’ ) but change that to apply_filters( ‘single_product_small_thumbnail_size’, ‘shop_thumbnail’ ) And you’ll have the smaller image size. You can also pass in “thumbnail” or any of the custom sizes you have in that spot without the … Read more

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