WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pagination not working (7 posts)

  1. sh_son
    Member
    Posted 1 year ago #

    Hello,

    I'm attempting to implement 'pagination' feature into a custom theme but for some reason I am not seeing any text or pagination. I have simply copy and pasted the codes from here (http://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/). But after reading through WordPress documentation it seems that I need to have pagination variables in order to have pagination navigation to work.

    Can someone point me to a right direction?

    Thank you.

  2. tomontoast
    Member
    Posted 1 year ago #

  3. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    from the linked tut:

    <?php if (function_exists("pagination")) {
        pagination($additional_loop->max_num_pages);
    } ?>

    this $additional_loop depends on your used query;

    for a 'normal' loop this might need to be replaced with $wp_query

    it might help if you paste the full code of your template into a pastebin and post the link to it here - see http://codex.wordpress.org/Forum_Welcome#Posting_Code

  4. sh_son
    Member
    Posted 1 year ago #

    Thank you, alchymyth.

    I have posted the template code into pastebin here.
    As of now I do not have any functions/code relating to pagination, as it kept failing to work.

  5. sh_son
    Member
    Posted 1 year ago #

    I would also like to add that pagination plugins such as 'WP-paginate' does not work.
    I'd only assume that I am missing a key piece of code, still going through google search and WordPress documentations.

  6. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    add the 'paged' parameter to this line:

    <?php $the_query = new WP_Query('showposts = 5');?>

    like:

    <?php $the_query = new WP_Query('posts_per_page = 5 & paged = ' . get_query_var('paged'));?>

    then try for instance these basic pagination links somewhere after the <?php endwhile;?>

    <?php next_posts_link('Older Entries ยป', $the_query->max_num_pages); ?>
    <?php previous_posts_link('Newer Entries', $the_query->max_num_pages); ?>

    http://codex.wordpress.org/Class_Reference/WP_Query
    http://codex.wordpress.org/Function_Reference/next_posts_link
    http://codex.wordpress.org/Function_Reference/previous_posts_link

  7. akumar_xavient
    Member
    Posted 11 months ago #

    Hey Guys ,
    Must use
    global $paged,$wp_query;

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.