Avoiding page loop

I would highly recommend you to make one of those wp query calls the main query & all others as secondary queries. That will make your life much easier in the long run. If you absolutely want to disable the main query, wordpress doesn’t have a direct filter for that. You can however do a … Read more

Show only one category in main query, issues on tag page

If the only issue you want to correct is the output of single_tag_title, you can correct the value via a filter by grabbing the tag query var directly: function wpa90852_fix_tag_title(){ $tag = get_term_by( ‘slug’, get_query_var(‘tag’), ‘post_tag’ ); return $tag->name; } add_filter( ‘single_tag_title’, ‘wpa90852_fix_tag_title’ );

Modify query after meta value

Here’s an example using WP_Query‘s meta_query to query posts between two meta key values: $meta_query = array( array( ‘key’ => ‘event_date’, ‘value’ => array( $date_start, $date_end ), ‘compare’ => ‘BETWEEN’ ) ); $args = array( ‘posts_per_page’ => -1, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value’, ‘meta_query’ => $meta_query ); $results = new WP_Query( $args );

Query specific number of posts for each post type in specific order

You can use WP_Query() with paged array key to pass the current page number: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘articles’, ‘posts_per_page’ => 4, ‘paged’ => $paged ); $articles = new WP_Query($args); //////////////////////////////// $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 1, ‘meta_query’ => array( array( ‘key’ => … Read more

wp_query select if have comments

You might try this: add_filter( ‘posts_where’, ‘filter_where’ ); $query = new WP_Query($args); remove_filter( ‘posts_where’, ‘filter_where’ ); where function filter_where( $where=”” ) { $where .= ” AND comment_count > 0 “; return $where; } to get posts with comments.

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