$post breaking container loop
$post breaking container loop
$post breaking container loop
Use this for pagination <?php $paged = ( get_query_var( ‘paged’ ) ) ? absint( get_query_var( ‘paged’ ) ) : 1; $mostpopular_args=array( ‘post_type’ => ‘post’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘view_count’, ‘paged’ => $paged, ‘posts_per_page’ => ’10’, ); $wp_query = new WP_Query($mostpopular_args); while ($wp_query->have_posts()): $wp_query->the_post(); get_the_title(); endwhile; global $wp_query; $big = 999999999; // need an unlikely … Read more
You should definitely be using prepare in this case, as your query is accepting input. It would be quite trivial for someone to compromise your database otherwise. Here we also use the new-in-4.0 esc_like method: $like=”%” . $mydb->esc_like( $facility_name ) . ‘%’; $results = $mydb->get_results( $mydb->prepare( “SELECT facility_name FROM facility WHERE facility_name LIKE %s LIMIT … Read more
To Ajaxify the request you need two parts, a php function, hooked to the wp_admin_ajax ( and the wp_admin_ajax_nopriv if you want it to be available for non logged in user) and a JavaScript to request the AJAX. PHP add_action(‘wp_ajax_getpost_by_year’,’process_getpost_by_year’); add_action(‘wp_ajax_nopriv_getpost_by_year’,’process_getpost_by_year’); function process_getpost_by_year(){ $year = $_REQUEST[‘year’]; $args = array( ‘post_type’ => ‘post’, ‘ignore_sticky_posts’ => 1, … Read more
Try to set 3-rd parametr for wp_list_pluck function, as i see if it’s not set then there’s happaning an unnessesery, for you, loop. Try to set it to true or some, not existing in Object, key. Hope it helps.
Since version 4.0 is available ‘type’ option for ‘orderby’ argument in WP_Query. Also, thanks to the more powerful ORDER BY in WordPress 4.0 you can control how posts of a post type are ordered. Example (untested): $q = new WP_Query(array( ‘post_type’ => array(‘map’,’item’), ‘orderby’ => array( ‘type’ => ‘DESC’, ‘title’ => ‘ASC’ ) ));
I resolved my similar issue (see below code block) by modifying the path to wp-load.php. Actually I used Frankie Jaret’s uri parse script which really only works on the default install but, meh, that’s what I use. I’m sure you can find a function that will parse it out where ever it may reside. Code … Read more
How do I get a nested query to only display content that the main query outputed
What you can do is the following: http://codex.wordpress.org/Function_Reference/get_posts_by_author_sql <?php $where = get_posts_by_author_sql( ‘post’, true, $user->ID); // get post query global $wpdb; $query = “SELECT ID FROM $wpdb->posts $where”; $post_ids = $wpdb->get_var( $wpdb->prepare( $query, ‘Get all posts’ ) ); ?> Did not try it but something simular in your case should help.
Optimising specific Query with ACF meta objects