Show posts from category specified using a custom field

Finally solved it! I needed to add this at the end of each loop 🙂 <?php $my_query = new WP_Query(array( ‘category_name’ => get_post_meta($post->ID, ‘featured’, true), ‘posts_per_page’ => 5, )); if ($my_query->have_posts()): ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> content etc goes here <?php endwhile; ?> <?php endif; ?><?php wp_reset_query(); ?> many thanks James

Sort posts alphabetically by category/custom taxonomy, insert divider between different types

after some trials I’ve got one solution that seems to be good but I need some tweaking help <ul class=”list-ensemble”> <?php $terms = get_terms(“production_co_type”); $count = count($terms); if ( $count > 0 ){ echo “<ul>”; foreach ( $terms as $term ) { echo ‘<li class=”title”>’ . $term->name . ‘</li>’; $args = array ( ‘post-type’=> ‘shows’, … Read more

Best Query for blog posts

Do the following: Create a blank page with the name “Blog” or “News” or whatever you like to call it. Go to Settings -> Reading and select A static page from Front page displays section. Choose your front-page from the Front page dropdown box, and your blog page (the page you created in step 1) … Read more

Querying a query

// store the IDs of the posts we’ve already displayed to prevent duplicates $used_ids = array(); $highlights_posts = request_highlights($slides_id); foreach( $highlights_posts as $post ) { setup_postdata($post); // check if we’ve already done this post if(in_array($post->ID,$used_ids)){ // skip to the next one continue; } // we haven’t done this post before, add it’s ID to the … Read more

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