Here is what I have.
I love the pagination navigation on the bottom of that page. It's super clean and awesome.
That page is generated from a shortcode, and by my best estimation, the pagination is generated by this code....
$big = 999999999; // need an unlikely integer
echo '<div class="pagination">';
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'prev_next' => True,
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
<?php endif ?>
Now moving on. http://www.briarhillcrestwoodky.com/subdivision/briar-hill-estates/
That page is generated automatically by WordPress -- and it just has a wimpy "Older Post" pagination navigation.
How can I force a uniform pagination across the site? Ideally, it I could add it as a drop in plugin etc that would be great. If I have to edit the template I could try that, but I'm trying to avoid that so I can do this with other themes/sites as well.
Is it possible to filter the pagination navigation and match the shortcode I'm using?
Hopefully this makes sense.
Hello scott, I'm afraid you have to edit the theme.. But yeah its simple. I guess you are using skeleton_wp theme with a child theme. Go to your base theme and edit the following file.
Remove that if loop and replace with your code.
You know I highly recommend you to try wp pagenavi plugin.
More than 3 and half million people using that plugin. Its a good plugin. I use that plugin in all my sites. Many theme supports that plugin.
Check this screenshot
So go ahead and give it a try.
If you are going to install wp pagenavi plugin then use this code instead of the codes you mentioned above..
<?php wp_pagenavi(); ?>
That one line code will take care of everything..
Scott Hack comments:
That sucks that I can't do it any other way... blah! I've used that plugin before, but I don't want to use it in the future.
I could write my code into a function and call that instead of the wp-navi function and do it the same way i guess.
Filtering and substituting my pagination would be so much nicer :(
I have no idea why you hate that plugin that much...
Yes if you are a programmer, its easy to create a function and call it in your theme. Infact wordpress already has a built-in function for pagination. Your shortcode is based on this function..
But still i'm afraid you have to edit your theme to use that. Because as of now your theme uses function like this for pagination..
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'skeleton' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'skeleton' ) ); ?></div>
</div><!-- #nav-below -->
<?php endif; ?>
I don't think you can use filter to replace that function. But you can still hide it using css display:none; property. But its not the proper way..
Abdelhadi Touil answers:
I see you want pagination without using a plugin, and without editing your theme files, that means you need a filter to do that. I'v searched around but I didn't find any solution like that, there are functions but they all need theme modifiaction, such as:
For me I use this plugin (I'v used wp-pagenavi in the past but didn't like it):
They seem to have the same pagination style now. Has this been done? Thanks!
Scott Hack comments:
I modified the theme. I am NOT opposed to using a plugin. As a matter of fact, I am using a plugin to generate the navigation now, but it sounds like I can't filter the default next and previous links with my custom function and I instead have to edit the theme files. If someone knows another way, that is what I would be interested in.