Order posts by more than one variable (meta_key and publish date AND time)

I found this link about “a more powerful ORDER BY in WordPress 4.0” and it led me to try this code: <?php $query = new WP_Query( array( ‘post_type’ => ‘result’, ‘posts_per_page’ => 100, //’paged’ => $paged, ‘meta_key’ => ‘event_date_results’, ‘orderby’ => array( ‘meta_value_num’ => ‘DESC’, ‘post_date’ => ‘DESC’), //’order’ => ‘DESC’, ‘meta_value’ => date(‘Ymd’), ‘meta_compare’ … Read more

Multiple Meta_values

$args = array( “numberposts” => -1, ‘post_type’ => ‘page’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘page_type’, ‘value’ => 1, ‘compare’ => ‘=’ ), array( ‘key’ => ‘page_type’, ‘value’ => 3, ‘compare’ => ‘=’ ) ) ); $city_ids = get_posts($args);

Can’t get meta values to save

Figured it out: There was a space in the field ID, and the $_POST key would collapse it. So the ID’s weren’t matching up in the foreach loop in my save function. I solved this with a sanitizing function on the IDs for my meta fields. I was further confused because my admin notices that … Read more

Create Shortcode shows only posts with custom_field meta

You need your shortcode to accept attributes. A shortcode with attributes would look like: [publication year=”2017″] Then in your add_shortcode callback function you receive attributes in the first parameter of the function: function wpse_279094_publication_shortcode( $atts ) { echo $atts[‘year’]; } add_shortcode( ‘publication’, ‘wpse_279094_shortcode’ ); You want to be able to account for a user not … Read more

Get the total Author Favorited posts

<?php $args22 = array( ‘post_type’ => array (‘menus’, ‘recipes’ ), ‘author’ => get_queried_object_id(), ‘meta_query’ => array( ‘meta_key’ => ‘simplefavorites_count’, ‘value’ => ‘0’, ‘compare’ => ‘>=’, ), ); $my_query = new WP_Query( $args22 ); echo ‘Found posts: ‘ . $my_query->found_posts . ‘<br />’; // declare variable and set total votes to 0 $total_fav_count = 0; if … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)