Order query by meta_value with multiple custom fields

You can use meta_query to get only posts with display_submenuexpositions = true and order them by order_submenuexpositions. $args = array( ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘order_submenuexpositions’, ‘meta_query’ => array( array( ‘key’ => ‘display_submenuexpositions’, ‘value’ => ‘true’, ‘compare’ => ‘LIKE’ ) ) ); $query_posts( $args );

Custom Field Template seriously messed up in WP 3.1.1

This Plugin is loading quite a lot of scripts: wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘jquery-form’ ); wp_enqueue_script( ‘date’, “https://wordpress.stackexchange.com/” . PLUGINDIR . “https://wordpress.stackexchange.com/” . $plugin_dir . ‘/js/date.js’, array(‘jquery’) ); wp_enqueue_script( ‘bgiframe’, “https://wordpress.stackexchange.com/” . PLUGINDIR . “https://wordpress.stackexchange.com/” . $plugin_dir . ‘/js/jquery.bgiframe.js’, array(‘jquery’) ) ; wp_enqueue_script( ‘datePicker’, “https://wordpress.stackexchange.com/” . PLUGINDIR . “https://wordpress.stackexchange.com/” . $plugin_dir . ‘/js/jquery.datePicker.js’, array(‘jquery’) ); … Read more

Display two custom values from a post

How about: $thumb = get_post_meta( $post_id, ‘thumb’, true ); $url = get_post_meta( $post_id, ‘website’, true); echo “<a href=”https://wordpress.stackexchange.com/questions/24970/$url”><img src=”$thumb” /></a>”; The get_post_meta() function is ideal when you know ahead-of-time the names of the fields you want to retrieve. Setting the third parameter to true tells it that you want to return a single value, and … Read more

Conditional custom field query

I found this: http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query I have modified the date to retrieve the last 15 days. It’s untested, but should work. $expireDays=”15″; $querystr = ” SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->posts.post_status=”publish” AND $wpdb->posts.post_type=”post” AND $wpdb->posts.post_date >= ( CURDATE() – INTERVAL $expireDays DAY ) ORDER BY $wpdb->posts.post_date DESC “; $pageposts = $wpdb->get_results($querystr, … Read more

Custom fields ‘for’ custom taxonomy?? Can someone explain why?

Custom fields for custom taxonomies are nothing more than custom templates. For example, you can remove the template of the post_tag taxonomy via remove_meta_box() function and add custom template via add_meta_box() function. Examples Remove tags template: /* Remove default post tags template. */ add_action( ‘admin_menu’ , ‘example_remove_taxonomy_template’ ); /** * Remove taxonomy template * * … Read more