Call WordPress 4.1 built-in paging navigation

WordPress thirty-one 14.2K Reading mode

WordPress 4.1 has been released for some time, and many new functions have been added. The built-in paging navigation is very practical, and other third-party paging codes and plug-ins are no longer needed.

 Calling WordPress 4.1 built-in paging navigation - picture 1

In fact, paging navigation has been built into the default theme of previous versions, but it is not integrated into the program. This time, WordPress version 4.1 is officially integrated into the program as the default function.

Paging navigation calling function:

  1. <? php
  2.     the_posts_pagination(  array (
  3. 'prev_text'=>Previous page,
  4. 'next_text'=>Next page,
  5.         'before_page_number' => '<span  class = "meta-nav screen-reader-text" >The</span>',
  6.         'after_page_number' => '<span  class = "meta-nav screen-reader-text" >Page</span>',
  7.     ) );
  8. ?>

Note: WordPress versions before 4.1 are not supported

Add to the appropriate location of the theme index, archive and other templates, and match with the corresponding style to achieve responsive conversion, as shown in the figure:

调用 WordPress 4.1 内置分页式导航-图片2

Built in paging navigation effect picture
The upper is the normal style, and the lower is the style of the mobile device.

 

Expand Style Code
open shrink

  1. /**Equal to or greater than 550px normal mode**/
  2. @media  screen  and ( min-width 550px ) {
  3.     .pagination {
  4.          float : right ;
  5.     }
  6.     .pagination a, .pagination a:visited {
  7.          float left ;
  8.          background #fff ;
  9.          margin : 0  5px   10px  0;
  10.          padding 8px   11px ;
  11.          line-height : 100%;
  12.          border 1px   solid   #ebebeb ;
  13.          border -radius:  2px ;
  14.     }
  15.     .pagination .current, .pagination .dots {
  16.          background #fff ;
  17.          float left ;
  18.          margin : 0  5px  0 0;
  19.          padding 8px   11px ;
  20.          line-height : 100%;
  21.          border 1px   solid   #ebebeb ;
  22.          border -radius:  2px ;
  23.     }
  24.     .pagination span.pages {}
  25.     .pagination span.current, .pagination a:hover {
  26.          background #0088cc ;
  27.          color #fff ;
  28.          border 1px   solid   #0088cc ;
  29.     }
  30.     . screen -reader-text, .pages  {
  31.          display none ;
  32.     }
  33. }
  34. /**550px or less for mobile devices**/
  35. @media  screen  and ( max-width 550px ) {
  36.     .pagination {
  37.          background #fff ;
  38.          border 1px   solid   #ebebeb ;
  39.          border -radius:  2px ;
  40.     }
  41.     .pagination .nav-links {
  42.          min-height 30px ;
  43.          position relative ;
  44.          text-align center ;
  45.     }
  46.     .pagination .current . screen -reader-text {
  47.          position static  ! important;
  48.     }
  49.     . screen -reader-text {
  50.          height 1px ;
  51.          overflow hidden ;
  52.          position absolute  ! important;
  53.     }
  54.     . page -numbers {
  55.          display none ;
  56.          line-height 25px ;
  57.          padding 5px ;
  58.     }
  59.     .pagination . page -numbers.current {
  60.          text-transform uppercase ;
  61.     }
  62.     .pagination .current {
  63.          display inline - block ;
  64.     }
  65.     .pagination .prev,
  66.     .pagination .next {
  67.          background #0088cc ;
  68.          color #fff ;
  69.          display inline - block ;
  70.          height 29px ;
  71.          line-height 29px ;
  72.          overflow hidden ;
  73.          padding 2px   8px ;
  74.          position absolute ;
  75.          border 1px   solid   #0088cc ;
  76.     }
  77.     .pagination .next {
  78.          border -radius: 0  2px   2px  0
  79.     }
  80.     .pagination .prev {
  81.          border -radius:  2px  0 0  2px ;
  82.     }
  83.     .pagination .prev a,
  84.     .pagination .next a{
  85.          color #fff ;
  86.          line-height 20px ;
  87.          padding : 0;
  88.          display inline - block ;
  89.     }
  90.     .pagination .prev {
  91.          left : 0;
  92.     }
  93.     .pagination .prev:before {
  94.          left : - 1px ;
  95.     }
  96.     .pagination .next {
  97.          right : 0;
  98.     }
  99.     .pagination .next:before {
  100.          right : - 1px ;
  101.     }
  102. }

If your theme is non responsive, just add the normal mode style (remove the media query judgment @ media screen And), see the specific effect Home page Bottom pagination.

Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!

 weinxin
My Wechat
Copyright Notice
Please indicate the source and link of the original article reprinted on this site. Thank you for your cooperation!
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 
 Robin
five hundred and ninety-eight million eight hundred and forty-five thousand and six
Comments thirty-one    Visitors twenty-six    Author three
    •  Great Counselor Network
      Great Counselor Network three

      Support Brother Bird! The theme is good, and we are paying close attention to it!

      •  Abbott
        Abbott two

        Brother Bird, it seems that the bottom of the home page is different from the navigation renderings

        •  Xiaoer Abutilon
          Xiaoer Abutilon two

          Like new topic

          •  Hezi Nethouse
            Hezi Nethouse two

            Support Brother Bird! Continuous attention!

            •  Kill the stars
              Kill the stars three

              I think it's very good

              •  Misong
                Misong zero

                Brother Bird, can you add the first and last page on this basis, or have an address, enter the number of pages, directly enter or click GO to jump the number of pages

                •  Flowers bloom and fall
                  Flowers bloom and fall one

                  Support brother bird, the new theme is very modern style, simple atmosphere!

                  •  Financing channel
                    Financing channel one

                    This function is a bit cool.

                    •  Selected Prose
                      Selected Prose five

                      Nice new version support!

                      •  aunsen
                        aunsen five

                        Is this also used for article pagination

                          •  Robin
                            Robin

                            @ aunsen This can only be used on the article list page
                            The article paging function has always been available

                          •  Tile mover
                            Tile mover zero

                            In this case, the paging plug-in can not be used anymore.

                            •  Ask Lawyer
                              Ask Lawyer zero

                              pretty good

                              •  Allied source
                                Allied source three

                                I also found the new functions in 4.1

                                •  Selected Prose
                                  Selected Prose five

                                  Beautiful way

                                  •  Eight claw print
                                    Eight claw print four

                                    test

                                    •  tonjay
                                      tonjay one

                                      Brother Bird, how to remove the code generated in paging navigation:
                                      Posts navigation

                                        •  Robin
                                          Robin

                                          @ tonjay Use display: none; hide

                                            •  Nine
                                              Nine zero

                                              @ Robin Is it good for optimization to hide it like this? I don't understand. It is said that the h1 label is not good

                                          •  sinsky
                                            sinsky one

                                            Why don't they display? They don't display after every attempt. The version is 4.1.1. In addition, you can't see the navigation on your home page.

                                            •  alalala
                                              alalala zero

                                              Is there a right added to line 97 and line 100 of the code. The "Next" button is not to the right during adaptation, but to the right after deleting a right

                                              •  BOKE123
                                                BOKE123 five

                                                This pagination page number is very powerful, not bad

                                                •  one hundred and eleven
                                                  one hundred and eleven zero

                                                  I want to say that your website scroll bar scrolling on the touch pad on the MAC system is anti human.

                                                  •  ebichu
                                                    ebichu zero

                                                    But the paging in the post type custom type archive page is invalid,

                                                    •  ha-ha
                                                      ha-ha zero

                                                      Ah ha ha ha ha ha ha ha ha ha

                                                      •  Win7en Paradise
                                                        Win7en Paradise seven

                                                        I think this is pretty good. I strongly recommend it. It's really easy to use. It's very easy to use.

                                                        •  The greatest truths are the simplest
                                                          The greatest truths are the simplest two

                                                          I used to use your blog theme, wokla.iok.la

                                                          •  Baizhi..
                                                            Baizhi.. zero

                                                            It doesn't work, nothing is displayed

                                                           anonymous

                                                          Comment

                                                          Anonymous netizens
                                                           :?:  :razz:  :sad:  :evil:  :!:  :smile:  :oops:  :grin:  :eek:  :shock:  :???:  :cool:  :lol:  :mad:  :twisted:  :roll:  :wink:  :idea:  :arrow:  :neutral:  :cry:  :mrgreen:

                                                          Drag the slider to complete validation