Tag Info

New answers tagged

0

The problem is that your pagination function is looking for page parameter in the global query but you are using a custom query to show your posts. You have two options: First option: Pass the custom query object to pagination function: In the pagination option, instead of using the global query object, use the custom query passed as argument: function ...


0

Change $my_query to $wp_query. In my_simone_paging_nav(), add the global $wp_query so that get_query_var can find paged.


0

You have to create a php file named search.php. Inside that file, write the code below: <?php get_header(); ?> <?php if( have_posts() ) : while( have_posts() ) : the_post(); ?> <article class="entry"> <header class="entry-title"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ...


1

As I said, this whole setup you are after is not possible natively with pretty permalinks. Your setup probably works with default permalink structure as both queries (the main query and your custom query) read these permalinks in the same way. When you switch to pretty permalinks, the two queries on the single page interpret the URL differently causing one ...


-1

$args = array( 'cat'=>7, 'offset'=>4,'paged' => $paged); in this array use posts_per_page insted of offset $args = array( 'cat' => 7, 'posts_per_page' => 4,'paged' => $paged);


0

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', ...


1

So it look's like it is possible to make this function work with “ugly” and “pretty” permalinks. Here is the code: <?php global $wp_query; //structure of "format" depends on whether we're using pretty permalinks if( get_option('permalink_structure') ) { $format = '?paged=%#%'; } else { $format = 'page/%#%/'; } $big = ...


1

I have actually just finished a function for my own personal use yesterday as I needed something a little bit more flexible for all queries. I've decided that I needed at least 5 page numbers to be visible at all times if there were more than 5 pages. Also, I needed a link back to the first and last pages Further more, I needed the flexibility to switch ...


1

As I already stated in a comment to your answer, you should never make use of query_posts Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new ...


-1

You Can Display you custom post type using this method your pagination can work !!! <?php query_posts( array( 'post_type' => 'post', 'posts_per_page' => '2', 'paged' => get_query_var( 'paged' ) ) ); if (have_posts() ) : while (have_posts() ) : the_post(); ?> <!-- Start your post. Below an example: --> <div ...


0

Instead of a function to place on functions.php, I find a workaround that can be placed on a template file: <?php global $authordata, $post; query_posts( array( 'author' => $authordata->ID, 'post_type' => 'post', 'post__not_in' => array( $post->ID ), 'paged' => $paged, 'posts_per_page' => 5 )); if (have_posts()) : ...


0

In your code after global $authordata, $post; add $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; and change your code from $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post_type' => 'kenniscentrum', 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) ); to $authors_posts = get_posts( ...


0

In a random query you will get duplicates between two different draws. Since each draw is independently random from the other, there is no much meaning to paging. If you set the random seed to constant then it is not random any more and you get paging working. Storing the seed in a cookie means that there is randomness for different users but not for the ...


-1

I found this article and got it to work <div class="posts"> <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $the_query = new WP_Query( 'cat=16&paged=' . $paged ); ?> <?php if ( $the_query->have_posts() ) : ?> <?php while ( $the_query->have_posts() ) : ...


0

In all honesty, I really think that all your misery is caused by your pagination function as we have briefly discussed a while ago. You do have a couple of issues here that are contributing factor to the problems you are experiencing Changing the main query for a custom query for what ever reason is almost always a big headache and should be avoided at ...


0

Here is a slight variation of an answer I have done on about the same scenario. What differs here is that you want less posts_per_page on page one STEP 1 Remove query_posts. You should never ever use query_posts Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the ...


-1

Try this code here <?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; if($paged == 1){ $posts_per_page = 100; }else{ $posts_per_page = 300; } query_posts( array( 'posts_per_page' => $posts_per_page, 'post_type' => array( 'regularproducts', 'wpsc-product' ), 'paged' => $paged, )); ?>


0

Finally got this working nicely, this specific issue was just down to not flushing the rewrite rules (gets me everytime!) so it was fixed by simply navigating to the 'Permalinks' page in the WP admin area.


0

Please use the following code: $arg = array ( 'posts_per_page' => get_option('posts_per_page'), 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ) ); $wp_query = new WP_Query($arg); if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); // do something endwhile; ...


-2

Please remove code: <p style="text-decoration: line-through;">$paged = (get_query_var('paged') ? get_query_var('paged') : 1);</p> Use this one: $the_query = new WP_Query("posts_per_page=10&category_name=life-sciences&paged=".**(get_query_var('paged') ? get_query_var('paged') : 1)**); ?>



Top 50 recent answers are included