How to create pagination in page code in wordpress?

前端 未结 2 547
-上瘾入骨i
-上瘾入骨i 2021-01-25 04:47

Hi all I am a new of wordpress I want to create pagination in page but still can not . I try to download plugin or add code and serch in google in youtube but I still can not d

2条回答
  •  时光取名叫无心
    2021-01-25 05:07

    Create Function in function.php

    function sofg_pagination($max_num_pages,$paged,$page_id){
        if($max_num_pages > 1){
        echo '
    '; echo '
      '; echo '
    • First
    • '; for($i=1; $i<= $max_num_pages; $i++){ if($paged==$i){ echo '
    • '.$i.'
    • '; } else{ echo '
    • '.$i.'
    • '; } } echo '
    • Last
    • '; echo '
    '; } }

    Get Pagination Your listing page

    Define Before loop

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $page_id = get_the_ID(); 
    

    Use After Loop

    $max_num_pages_1 = $max_num_pages->max_num_pages;
    sofg_pagination($max_num_pages_1,$paged,$page_id);
    

    See pagination http://hiddenwhy.igexsolutions.com/blog/

提交回复
热议问题