New answers tagged

0

This is a nuts-and-bolts way of getting at this problem. This modifies the SQL query itself, but it's pretty much a 1 liner. I'm sure there are other ways, but this method is not very invasive to the query building process as it only mods the SQL at the end. Note I realize this method could be usurped by the syntax of a query builder at some point. First ...


3

As I far I know, get_posts() function can not be used to paginated results. It is intended to get an array of posts and it sets no_found_rows to true by default from WP 3.1. Pagination won't work unless you set it to false, or better, use WP_Query. numberposts is also a invalid argument. $paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1; ...


0

Your rule doesn't work for custom post types because pagename is the query var specific to the page post type. Your CPT query vars are the slugs you registered them with, doujinshi_en and doujinshi_jp. You might be able to fix it by adding in additional post types via pre_get_posts: function wpd_add_custom_types( $query ){ if( ...


2

Here's a workaround: First change the paginate_links() output type to: 'type' => 'array', Then we can collect the previous, current and next parts from the paginate_links() output. Here's a simple example where we target the relevant classes: $next = ''; $current = ''; $prev = ''; foreach( (array) $paginate_links as $link ) { ...


1

Got it to work, changing the regex from (.+) to (.*) Maybe helpful for others searching same rewrite on search and pagination. add_rewrite_rule('discover/interiors/interior-results/(.*)/page/([0-9]{1,})/?', 'index.php?pagename=discover/interiors/interior-results&tag1=$matches[1]&paged=$matches[2]', 'top' ); ...


0

In order to remove the duplicate posts, I used the below process in one of the theme I worked on. Create a global variable Store the post ID of first loop on the variable On next loop, use post__not_in to remove the already shown posts. Or, you can also check if current post id is in array of global variable and skip that post.


0

For any one struggling with this there is an answer here on SO. As I am going to use this in multiple places I used the function answer. Add to be functions.php: function current_paged( $var = '' ) { if( empty( $var ) ) { global $wp_query; if( !isset( $wp_query->max_num_pages ) ) return; $pages = $wp_query->max_num_pages; } else { ...


0

// Its working on home page set the "paged" parameter (use 'page' if the query is on a static front page) <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : '1'; $args = array ( 'nopaging' => false, 'paged' => $paged, 'posts_per_page' => '1', 'post_type' ...


0

This post on the WordPress forums should provide some assistance. It uses the paginate_links function to generate the output.


1

You need to set your paged arg in your $args array: $listing_args = array( 'post_type' => 'business', 'posts_per_page' => 10, 'meta_key' => 'listing_num', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'offset' => ($paged -1) * 10, 'paged' => ...


0

Put the following code in functions.php # +++++++++++++++++++++++++++++++Pagination ++++++++++++++++++++++++++++++++++++++ function kriesi_pagination($pages = '', $range = 2) { $prev = __('« Prev'); $next = __('Next »'); $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global ...


0

The reasons why you should not run query_posts() are perfectly outlined in this answer. Long story short: You overwrite the default query (that happens by WP core) and replace everything that was valid for this request with data that only matches for your secondary query. The function get_query_var() relies on the global $wp_query that gets reset by your ...


-1

try this code just change category name <?php $args = array( 'post_type'=> 'post', 'category_name' => 'blog', 'orderby' => 'post_date', //'posts_per_page'=>'1' 'paged' => get_query_var('paged') ); query_posts( $args ); ...


2

I did what Rarst told me to do. First I searched around in the Pods Framework documentation. This solved my problem. Here's what the code looks like right now. <?php $params = array( 'orderby' => 'publish_date.meta_value DESC', 'limit' => 10 ); $fltNewsPods = pods( 'fltnews', $params ); while ($fltNewsPods->fetch()) { echo ...


0

Modify main query on post type archive page Instead of direct modify main query, just use normal loop ( you can create post type template, in your case archive-portofolio.php ), and run your modifying query under filter pre_get_posts. Your normal loop on archive-portfolio.php <div class="row text-center small-up-1 medium-up-2 large-up-3 ...



Top 50 recent answers are included