New answers tagged pagination
0
This includes a hook for genesis however you can easily change it and the name of your portfolio slug.
function wpsites_npp_navigation_links() {
if( 'portfolio' == get_post_type() && is_single() ) {?>
<?php previous_post('« « %', 'Previous', 'no'); ?>
| <?php next_post('% » » ', 'Next', 'no'); ...
0
post_count property of query object will hold amount of posts queried.
Note that this is not often used and it is more common to display such elements by conditional logic (is_singular(), is_archive(), etc) or on template level.
PS query_posts() is evil and should not be used
0
It looks like a similar problem has received an answer; have you seen it?
Use two different post_per_page limits with infinite scroll
From that link:
Add a parameter to the href URI for the next posts link per JavaScript. For example ?ppp=2.
Add a filter to pre_get_posts, check if ppp is set (and a positive integer) and change the post_per_page parameter ...
0
Here's the direction to go, I think:
The WP Infinite Scroll plugin works by identifying your page's navigation and then, I think, loading the next link found there. So instead modifying the query on single.php, I'm now trying to modify the pagination.
I've tried several pagination functions, such as posts_nav_link() and twentytwelve_content_nav( ...
0
your string concatenation is broken. join parts of a string with ., not a comma, and separate arguments with an ampersand.
$wp_query->query('cat=61&showposts=5&paged=' . $paged);
0
I didn't entirely resolved my problem. My client changed his mind and didn't want the sorting anymore.
But concerning the paging, I managed to have it working by adding a new arg in my query, here is the code that made it worked for me :
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' ...
0
Based on the code you posted, you are not passing any meta parameters through to the pagination function. You will need to create links like :
<a href="<?php get_permalink(). '?paged=' . ($paged + 1) . '&meta_key='.$something.'&meta_value='.$somethingelse; //next link ?>">Link Text</a>
I assume your are processing that meta ...
1
They're not the same. Your news page is the posts page, and your recipes page is a page post type where you've used a custom query to load the posts. I can see that by looking at the classes being added to the body tag. I presume that your custom query has no pagination parameters being passed to it, but you'll have to show us the code in the template to ...
0
Currently (with WP 3.5.1) we ain't got any possibility (means: no hook or filter) to alter the output of the pagination. Everything inside the WP_Posts_List_Table class and its method pagination() and the WP_List_Table class method pagination is hard coded.
So your only chance would be to replace the $GLOBAL on the fly with a class that extends the core ...
0
I am assuming you are doing something like this:
if (have_posts()) {
while (have_posts()) {
the_post();
if(x == j){ //inject post here }
}
}
Injecting a post inside the Loop like that will cause the post count for that page to differ from the posts_per_page value, but it will not break pagination (which seems to be your primary question). ...
1
Remove all query code from the template and just leave the default loop. In your example code you're overwriting the query in the template, in the code you pasted in the comments, you're running an entirely new query. These are both unnecessary when using pre_get_posts.
Put your pre_get_posts code in functions.php. You don't have to pass $paged or do ...
2
There are filters for previous_post_link and next_post_link functions which works in a different way from previous_posts_link_attributes and next_posts_link_attributes, I am not sure why this is not documented on the wordpress website.
function posts_link_next_class($format){
$format = str_replace('href=', 'class="next clean-gray" href=', $format);
...
3
You're overwriting the main query with a new query where you don't specify any tag parameters, which is why you're seeing all posts and not those specific to the tag you're viewing. The answer-
Do not modify the main query in the template.
There's almost never a legitimate reason to have to modify the main query this way. Remove the 3 lines starting from ...
2
OK, it seems that we have two errors here:
You should use posts_nav_link() instead of previous_post_link() and next_post_link(). The functions you used point to previous/next posts, not pages. You can refer to the WordPress Codex for more information.
You should place posts_nav_link() after endwhile so that it is not repeated for every single post excerpt ...
0
First, don't use query_posts.
There are no pagination functions that I can spot in your code. That
is a big problem if you want pagination to work.
Nor do you have a pagination parameter in your query_posts (which
you should not be using) arguments.
The simple pagination functions like next_posts_link may not
work in your case anyway, without complicated ...
0
There is a detailed article on this subject on the official WordPress Codex:
http://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
Basically, WordPress uses offset to calculate which posts to show for any given page. When you set offset manually, it overrides that.
There are two steps to fixing the problem:
Ensure offset is only ...
0
I'm not familiar with this plugin, but in looking at the source, I think you could do something like this (EDIT: This doesn't work, because the plugin bails if there is more than one tag per post, see below for a similar approach):
<!--FBGallery2 1234567890123456789 start=0 max=20 --><!--/FBGallery2-->
<!--nextpage-->
<!--FBGallery2 ...
0
The current page number is set by the main query, not by your embedded sub-query. Also, you really should not create a second query, alter the main query instead with a filter on pre_get_posts.
add_filter( 'pre_get_posts', 'add_custom_type_to_tag_archive' );
function add_custom_type_to_tag_archive( $query )
{
if ( ! is_main_query() or ! is_tag() )
...
1
Perhaps you can take a look at this question and the answers and check if you really want to use query_posts() as it is not recommended while dealing with posts pagination. Why not use pre_get_posts action instead? Or you can try something like this:
<?php
$custom_query = new WP_Query(array(
'post_status' => 'publish',
'post_type' ...
0
It can be done by AJAX, Read this tutorial which with a little modification can do what you want.
Top 50 recent answers are included
