How to exclude post from being queried based on custom meta value

According to the codex for WP_Query, you should be able to tack on some meta related arguments to your args array (this is untested): $review_args = array( ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘posts_per_page’ => ‘1’, ‘cat’ => 22, ‘meta_query’ => array( ‘key’=>’reviewed_by’, ‘value’=> $reviewed_by_array, ‘compare’=> ‘NOT IN’ ) ); $review_query = new WP_Query($review_args);

Paying to Access Custom Fields Per Post

This sounds like custom development work, I doubt there is a pre-built solution. At its most basic, I’d say you need to a membership solution. There are a several out there, some free, some premium. Then in your front-end you can wrap the display of all the custom fields with current_user_can() using a capability that … Read more

Add custom field to post with some part of url as value

I found this solution, it works great. I will share it here if someone else need it. $currenturl=”http://” . $_SERVER[‘SERVER_NAME’] . $_SERVER[‘REQUEST_URI’]; $id = $post->ID; if ( preg_match(‘/\?(.+)$/’, $currenturl, $matches) ) { $value = urldecode($matches[1]); add_post_meta($id, ‘my_new_custom_field_name’, $value, true); }

Unable to get the upcoming events for custom post

just changed the query a little $meta_query_args=array( ‘relation’ => ‘AND’, array( ‘key’ => ‘event-start-date’, ‘value’ => $date_today, ‘compare’ => ‘<‘, ) ); $loop = new WP_Query( array( ‘post_type’ => ‘events’, ‘posts_per_page’ => 5 , ‘meta_key’ => ‘event-start-date’, ‘orderby’ => ‘event-start-date’, ‘order’=>’desc’, ‘meta_query’ => $meta_query_args ) ); if($loop->have_posts()): while ( $loop->have_posts() ) : $loop->the_post(); but can … Read more

new WP_query using custom fields

This is what works in my query: <?php $argsfeature = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘page’, ‘order’ => ‘DESC’, ‘posts_per_page’ => ‘1’, ‘meta_key’ => ‘featuring’, ‘meta_value’ => ‘1’ ); ?> and this query works: <?php $argsarticles = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘page’, ‘order’ => ‘DESC’, ‘posts_per_page’ => ‘5’, ‘post_parent__in’ => array(10,11) ); … Read more