php - WordPress - Add Numeric Pagination. -


I am using numeric post navigation code in my WordPress theme. I have set the Blog Page Show to a maximum of 24 pages so that page navigation displays 8 pages. Ex: 1 2 3 ... 8 . But does page navigation actually show me 1 2 3? 8 . Now my question is, what is the error in the code given below instead of its dot? is showing, please help me anybody.

My code is,

  function wpbeginner_numeric_posts_nav () {if (is_singular ()) return; Global $ wp_query; / ** If only 1 page * / if ($ wp_query-> max_num_pages & lt; = 1) stop execution on return; $ Paged = get_query_var ('paged')? Absint (get_query_var ('paged')): 1; $ Max = interval ($ wp_query-> max_num_pages); / ** Add existing page to the array * / if ($ paged & gt; = 1) $ links [] = $ paged; / ** Add pages to the array around the current page * / if ($ paged & gt; = 3) {$ links [] = $ paged - 1; $ Link [] = $ page - 2; } If (($ paged + 2) & lt; = $ max) {$ links [] = $ paged + 2; $ Link [] = $ page + 1; } Echo & lt; Div class = "navigation" & gt; & Lt; Ul & gt; '. "\ N"; / ** Previous Post Link * / if (get_previous_posts_link ()) printf ('
  • % s & lt; / li & gt;' \ n ", get_previous_posts_link ()); / ** link on first page, plus pending if required * / if (! In_array (1, $ links)) {$ class = 1 == $ paged? 'Class = "active"': ''; printf ('
  • s ';} / ** Link to the current page, as well as $ links / $ ($ array) $ foreign exchange ($ array) if $ $ $ {$ class = $ paged == $ link? Class = "active" ':' '; printf (' & lt; a href = "% s" & gt;% s & lt; / a & gt; & lt; / li & Gt; '\ n ", $ square, esc_url (get_pagenum_link ($ link), $ link); } / ** The last page with the link, plus pending if required * / if (! In_array ($ max, $ links)) {if (! In_array ($ max - 1, $ links)) echo '& lt; Li & gt; ... & lt; / li & gt; '. "\ N"; $ Class = $ paged == $ Max? 'Class = "active"': ''; printf ('
  • s

    in the front page Page Navigation

      & lt; php wpbeginner_numeric_posts_nav ();? & Gt;    

    I think you might have some encoding problems because I think that instead of using it, 3 points ... You are using a special character called "horizontal ellipsis" -> ... which combines 3 points in the same letter (try to select both points and you can see the difference First example is 3 characters, and second, 1 single char).

    When the encoding is incorrect and the browser can not find a specific character in its character table, it will default to a question mark Will display as.

    There are several possible solutions:

    Change the character for simple points in your code where this is the comment:

      / ** From the final page Link, plus alpiece if necessary * /   <

    <<> & lt; Li & gt; of


    Try setting your page to UTF-8:

      & lt; meta http-equiv = "content-type" content = "text / html; charset = UTF-8" & gt;   

    your & lt; Head & gt; .


    Instead of displaying that particular, use the html special character code to display the character that is called the horizontal ellipse and it should be displayed like this: & Hellip;


    You can use the first solution, or any of the previous 2 solutions / I have given you to fix your problem

    Note :

    I just remembered that the encoding problem can come from the PHP itself, so in case of your script it is:

    mb_internal_encoding (" UTF-8 "); Source:

  • Comments

    Popular posts from this blog

    Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

    multithreading - PhantomJS-Node in a for Loop -

    c++ - MATLAB .m file to .mex file using Matlab Compiler -