FinDes
Forum Replies Created
Viewing 3 replies - 1 through 3 (of 3 total)
-
Forum: Fixing WordPress
In reply to: Custom Meta QueriesI am closer, with the code below, the Upcoming events show in the first loop, but the past events query duplicates the first upcoming event 4 times.
<h1>2013-14 Concert Season</h1> <?php $today = date('Ymd'); $args1 = array( 'type' => 'post', 'category_slug' => 'Featured1314', 'meta_key' => 'concert_date', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'concert_date', 'value' => $today, 'compare' => '>=' ) ), 'orderby' => 'meta_value_num', 'order' => 'ASC' ); $upcoming_query = new WP_Query($args1); if( $upcoming_query->have_posts() ) { ?> <h2>Upcoming Concerts</h2> <ul><?php while ( $upcoming_query->have_posts() ) { $upcoming_query->the_post(); ?> <li id="post-<?php the_ID(); ?>"><h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1><p><?php the_excerpt() ?></p></li> <?php } }?> </ul> <?php rewind_posts(); $today = date('Ymd'); $args2 = array( 'type' => 'post', 'category_slug' => 'Featured1314', 'meta_key' => 'concert_date', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'concert_date', 'value' => $today, 'compare' => '<' ) ), 'orderby' => 'meta_value_num', 'order' => 'ASC' ); $past_query = new WP_Query($args2); if( $past_query->have_posts() ) {?> <h2>Past Concerts</h2> <ul><?php while ( $past_query->have_posts() ) { $past_query->next_post(); ?> <li id="post-<?php the_ID(); ?>"><h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1><p><?php the_excerpt() ?></p></li> <?php } }?> </ul>Forum: Fixing WordPress
In reply to: Custom Meta QueriesI tried this and it netted the same results as before.
Forum: Fixing WordPress
In reply to: list posts in sidebar with matching custom fieldsHere is what I have so far, but there is something wrong with my query…
<?php echo("<ul>"); $ID = get_the_ID(); echo("<li>ID = " . $ID . "</li>"); $title = get_post_custom_values('Title', $ID); $season = get_post_custom_values('Season', $ID); echo("<li>Title = " . $title[0] . "</li>"); echo("<li>Season = " . $season[0] . "</li>"); echo("</ul>"); $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = $title[0] AND wpostmeta.meta_key = $season[0] AND wposts.post_status = 'publish' AND wposts.post_type = 'post' ORDER BY wposts.post_date DESC "; $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <ul> <?php if ($pageposts): ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a></li> <?php endforeach; ?> <?php else : ?> <li>Sorry no other episodes this season, yet.</li> <?php endif; ?> </ul>
Viewing 3 replies - 1 through 3 (of 3 total)