Check if meta_key exists in wp_list_pages
Check if meta_key exists in wp_list_pages
Check if meta_key exists in wp_list_pages
If you want to get post meta, then you just need to call get_post_meta() function and pass three arguments: current post id, your meta key and true value (what indicates that you want to receive only one value in return). Simply call echo get_post_meta( get_the_ID(), ‘_su_description’, true ); in your template and your meta value … Read more
Custom Field: Display only if a specific key is selected outside the loop
Edit your code thusly: $meta_key = ‘agency_email’; $agency_emails = $wpdb->get_col( $wpdb->prepare( “SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %s”, $meta_key ) ); var_dump( $agency_emails ); foreach ( $agency_emails as $ae ) { echo $ae; }
The meta_query parameter in WP_Query allows you to query posts that don’t have a certain custom field. Furthermore, you can check for multiple custom fields. With two queries in meta_query, you can fetch all posts that either don’t have a custom field, or have it set to 0: ‘meta_query’ => array( ‘relation’ => ‘OR’, array( … Read more
From the codex http://codex.wordpress.org/Class_Reference/WP_Query: $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘age’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘age’, ‘value’ => array(3, 4), ‘compare’ => ‘IN’, ) ) ); $query = new WP_Query($args); Look at the meta_query section. you can define the key and then all the possible … Read more
Here is what I ended up with: Basically, I had the logic of the timing at the bottom wrong. Figuring out times and dates and what note is hard… add_action(‘init’, ‘delete_unclaimed_apps’); function delete_unclaimed_apps() { $availapps = get_posts(array( ‘post_type’ => ‘appointment’, ‘post_status’ => ‘publish’, ‘meta_query’ => array ( array( ‘key’ => ‘app_status’, ‘value’ => ‘available’, ), … Read more
use $_GET[‘Price’] and $_GET[‘Region’] to get the price and region values from the url and add them to your query args. It is rather hard without any code to start from, but try something like $queryPrice = (strpos($_GET[‘Price’],’-‘) ? explode(‘-‘, $_GET[‘Price’]) : array($_GET[‘Price’], $_GET[‘Price’])); $queryRegion = $_GET[‘Region’]; $args = array( // all your args here … Read more
Ok, the problem came from the fact I was looping on categories to get the matching post. What I had to do was to get the desired categories and use it in my $args + some adjustments. <?php // Get the parent cat thanks to the page’s cat slug $parent_cat = get_category_by_slug( $cat[1] ); $cats_args … Read more
Try this : $value = get_post_custom_values( ‘banda_postmeta’, $post->ID ); $value = unserialize(“$value”); print_r($value); echo $value[‘social_networks_url’][‘twitter_url’]; Your social_networks_url are blank, so try echoing these values, it will echo the value. echo $value[‘page_builder_settings’].”<br />”; echo $value[‘date_of_birth’].”<br />”; echo $value[‘location’].”<br />”; Output : array (size=7) ‘social_networks_url’ => array (size=9) ‘twitter_url’ => string ‘wr’ (length=2) ‘facebook_url’ => string ” … Read more