Show individual author rank from query of cumulative post view count for all authors

First you can replace ‘posts_per_page’ => ‘10000000000’ with ‘posts_per_page’ => -1 to remove the limit. If you want to show the user rank, you can add a $rank counter in the foreach loop: $rank=0; // output the result: user, total postview count, latest post foreach ($output as $user){ $rank++; $profile = get_userdata($user[‘id’]); $query = get_posts( … Read more

Next/Prev posts on same page

Pass Paged into parameter array of query_posts You should set get_query_var( ‘paged’ ); if you want your query to work with pagination. $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args_news= array( ‘cat’ => 1, ‘posts_per_page’ => 2, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘numberposts’ => -1, ‘paged’ => $paged, ); query_posts( $args_news ); if ( … Read more

ACF Custom Field WP_Query, but need to get all posts, if field doesn’t exist

You can get both with an OR meta_query that also checks if the key does not exist: ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘event_date’, ‘compare’ => ‘NOT EXISTS’, ), array( ‘key’ => ‘event_date’, ‘value’ => date(“Ymd”, time()), ‘compare’ => ‘>’, ), ), ‘orderby’ => array( ‘meta_value_num’ => ‘DESC’, ‘date’ => ‘ASC’, ),

Unable To Get Published posts using query_posts

First off, you probably shouldn’t be using query_posts, which modifies WordPress’ main loop and is unsuited for pretty much any purpose (read When should you use WP_Query vs query_posts() vs get_posts()? for more info). There are numerous reasons why query_posts wouldn’t work as expected in this case. WordPress has two proper approaches to fetching posts: … Read more

greatest() function returns undefined property

I think you want to use get_var(), not get_row() – looking at the documentation, MySQL’s GREATEST just returns a single value. $results will then just be the value of the greatest (be it up or down). If you want the greatest up and the greatest down, use; $wpdb->get_row(“SELECT GREATEST(up) AS ‘up’, GREATEST(down) AS ‘down’ …”)

Adding Variables to post query

As toscho said, you can modify the query in the pre_get_posts hook. That hook gets the query object passed as an argument, so you don’t have to read a global variable. add_action( ‘pre_get_posts’, ‘wpse12692_pre_get_posts’ ); function wpse12692_pre_get_posts( &$wp_query ) { if( isset( $_SESSION[‘size’] ) && $_SESSION[‘size’] != ‘all’ ) { $wp_query->query_vars[‘meta_query’] = array( ‘key’ => … Read more

Filter Posts By Tag

here you go, The following returns all posts that belong to category 1 and are tagged “apples” query_posts( ‘cat=1&tag=apples’ ); Add this inside the page before the loop change ‘1’ and ‘apples’ to whatever category and tag you want. If you must use query_posts(), make sure you call wp_reset_query() after you’re done. look here for … Read more

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