Ask your WordPress questions! Pay money and get answers fast! (more info)

Help with uniform pagination navigation. WordPress

  • SOLVED

Here is what I have.

http://www.briarhillcrestwoodky.com/test-page/

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
) );
echo '</div>';
else: ?>
Nothing found
<?php endif ?>
<?php
}


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.

Answers (3)

2013-04-24

Giri answers:

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.

https://github.com/simplethemes/skeleton_wp/blob/master/skeleton/loop.php#L178

Remove that if loop and replace with your code.

You know I highly recommend you to try wp pagenavi plugin.

[[LINK href="http://wordpress.org/extend/plugins/wp-pagenavi/"]]http://wordpress.org/extend/plugins/wp-pagenavi/[[/LINK]]

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

http://wordpress.org/extend/plugins/wp-pagenavi/screenshots/

So go ahead and give it a try.


Giri comments:

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 :(


Giri comments:

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

http://codex.wordpress.org/Function_Reference/paginate_links

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">&larr;</span> Older posts', 'skeleton' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</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..




2013-04-24

Abdelhadi Touil answers:

Hi.
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:

[[LINK href="http://www.teachmehowtocode.com/how-to-enable-wordpress-pagination-without-plugin-833/"]]http://www.teachmehowtocode.com/how-to-enable-wordpress-pagination-without-plugin-833/[[/LINK]]

[[LINK href="http://wordpressexperts.net/how-to-add-pagination-in-wordpress-without-plugins-its-easy/"]]http://wordpressexperts.net/how-to-add-pagination-in-wordpress-without-plugins-its-easy/[[/LINK]]

For me I use this plugin (I'v used wp-pagenavi in the past but didn't like it):

[[LINK href="http://wordpress.org/extend/plugins/wp-paginate/"]]http://wordpress.org/extend/plugins/wp-paginate/[[/LINK]]

Good luck.

2013-04-24

idt answers:

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.