How to query for a week using key => value WP_Query argument notation?

There isn’t a week query variable, but there is w: http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters w (int) – Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependent on the “start_of_week” option. Your args should look like this: $args = array(‘category_name’ => ‘whats-happening’, ‘year’ => 2012, ‘w’ => 46 ,’paged’ => $paged);

Filter Media Library by author or post_parent

The only way to do it is using a query filter I think function wpse156319_posts_where( $where, $query ) { global $wpdb; $where .= $wpdb->prepare( ‘ AND (‘ . $wpdb->posts . ‘.post_parent = %s OR ‘ . $wpdb->posts . ‘.post_author = %s)’, $_POST[‘id’], get_current_user_id() ); return $where; } which you just add in the ajax_query_attachments_args instead … Read more

Duplicate Queries

Generally speaking, you could use the WP Transients API to save the query. // Get any existing copy of our transient data if ( false === ( $special_query_results = get_transient( ‘special_query_results’ ) ) ) { // It wasn’t there, so regenerate the data and save the transient $special_query_results = new WP_Query( ‘cat=5&order=random&tag=tech&post_meta_key=thumbnail’ ); set_transient( ‘special_query_results’, … Read more

How to delete a transient on post/page publish?

I am considering it for publication of a new post. Add the below code in your active theme’s functions.php file. function wpse_delete_query_transient( $post ) { // Deletes the transient when a new post is published delete_transient( ‘d_results’ ); } add_action( ‘new_to_publish’, ‘wpse_delete_query_transient’ ); This will delete the transient every time a new post is published. … Read more

Sort X categories by last update and show image

Here’s one solution: global $wpdb; $cat_array = $wpdb->get_results( ” SELECT terms.*, posts.ID as post_ID FROM wp_terms terms JOIN wp_term_taxonomy term_taxonomy ON terms.term_id = term_taxonomy.term_id JOIN wp_term_relationships term_relationships ON ( term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id AND term_taxonomy.taxonomy = ‘category’ ) JOIN wp_posts posts ON ( posts.ID = term_relationships.object_id AND posts.post_type=”post” AND posts.post_status=”publish” ) GROUP BY terms.term_id ORDER BY … Read more

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