westleymon
Forum Replies Created
-
Renaming the object-cache.php in /wp-content also worked for me. Thanks!
Forum: Plugins
In reply to: [Contact Form 7] [Plugin: Contact Form 7] Populate Select Box from databaseI found a solution posted here.
They populated the dropdown with post titles from a specified category.
The file you will need to modify is select.php and it is under the “modules” folder with in cf7.
Open up select.php and on line 93 (right under $label = $value;)
paste the following code.if ($name == 'events') { $cf7_dropdown = new WP_Query("cat=1"); while($cf7_dropdown->have_posts()) : $cf7_dropdown->the_post(); if ( !in_array( get_the_title(), $do_not_duplicate ) ) { $do_not_duplicate[] = array_unique($do_not_duplicate); $html .= '<option value="' . esc_attr(get_the_title()) . '"' . '>' . esc_html(get_the_title()) . '</option>'; array_push($do_not_duplicate, get_the_title()); } endwhile; } else {
In my case, I had a custom post type (Events), that needed to get a list of all events from this day forward (which is why the query string has the meta_value and meta_compare within it).
Here is the code I used:
// custom for events list if ($name == 'events') { $cf7_dropdown = new WP_Query('post_type=event&numberposts=-1&order=ASC&meta_key=event_date&meta_compare=>=&meta_value=' . date("m/d/Y") . '&orderby=meta_value_num'); while($cf7_dropdown->have_posts()) : $cf7_dropdown->the_post(); setup_postdata($post); $custom = get_post_custom($post->ID); $html .= '<option value="' . esc_attr(get_the_title()) . ' - ' . $custom["event_date"][0] . '"' . '>' . esc_html(get_the_title()) . ' - ' . $custom["event_date"][0] . '</option>'; endwhile; } else { //end custom for events list
Do note that with this, you’ll need to add a another closing bracket to the very end of the file – changing
<?php } ?>
to<?php } } ?>
Let me know if you’ve got any questions…
Forum: Fixing WordPress
In reply to: Exclude posts from wp_query based on meta_valueFound the answer to my question on this post.
Changed my code to a get_posts function which enabled me to use the meta_compare option in the query.
For anyone who might be wondering, my new code looks like this:
$postslist = get_posts('post_type=event&numberposts=4&order=ASC&meta_key=event_date&meta_compare=>=&meta_value=' . date("m/d/Y") . '&orderby=meta_value_num'); foreach ($postslist as $post) : setup_postdata($post); // post layout endforeach;
Enjoy!