Sort Events by Venue Title – Sort Post set by related post ids

You can use meta__value in orderby e.g. ‘post_type’ => ‘tribe_events’, ‘posts_per_page’ => -1, ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘event_title’ => array( ‘key’ => ‘post.title’, ), ‘event_id’ => array( ‘key’ => ‘EventVenueID’, ), ), ‘orderby’ => ‘event_title’, Not tested but should work, this was introduced in 4.2 of WP – https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/

How to make MySQL search queries with quotes

Woah there. You’ve just opened up a can of SQL injection. I use the default get_query_var(‘s’) that I believe is automatically escaped by wordpress. Not quite – get_search_query() will do that, but get_query_var( ‘s’ ) gets the “raw” value. Regardless, always use wpdb::prepare or similar escaping before executing SQL: $query = $wpdb->prepare( “SELECT * FROM … Read more

Running Filter or Shortcode Before Query Prevents Excerpt from Showing

It seems you need to rest the post data before return the $postCount. Before return it, add the follow: wp_reset_postdata(); — There is a difference between wp_reset_query()and wp_reset_postdata(), as explained here. wp_reset_query() – ensure that the main query has been reset to the original main query. wp_reset_postdata() – ensures that the global $post has been … Read more

YearMonth datequery

To search for posts based on date, you can set up a quick instance of WP_Query. The best place to look is the official documentation, and in particular the section on the date parameters. A basic search for posts in a particular month will look a little like this: <?php $the_query = new WP_Query( array( … Read more

Bring a post to the top of the query if it’s in a certain category?

You will have to use 2 queries, where in the first loop you should use: $args = array( “post_type” => “post”, “post_status” => “publish”, “orderby” => “date”, “order” => “DESC”, “posts_per_page” => 20, ‘post__in’ => cat, ); (The Query) And in the second: $args = array( “post_type” => “post”, “post_status” => “publish”, “orderby” => “date”, … Read more

Get featured image outside the loop using foreach

First you will need to get a list of all available sizes on your site. This function get_intermediate_image_sizes() will do that. You can then pass the results of that to image_get_intermediate_size() along with the post id and <?php $sizes = get_intermediate_image_sizes(); ?> <?php foreach($major_data as $postID) { ;?> <?php $postData = get_post( $postID );?> <?php … Read more

Fetch only categorized posts

category__not_in is a private query var. This means you can only use it when constructing a query in PHP, not in a url. You would have to construct your own custom public query var and bind that to a filter that reads the category and then changes the query accordingly.

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