1179 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 6-7 years
mabuc says

Hello guys,

does anyone here know how to add span between

<a href="http://localhost/Wordpress/?paged=2" class="page">2</a>

to this

<a href="http://localhost/Wordpress/?paged=2" class="page"><span>2</span></a>

I am using the plugin wp-pagenavi, anyone tried this before?

Thanks for the help.. ;)

2444 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
digitalimpact says
1179 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 6-7 years
mabuc says

any other solutions? aside of this

2444 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
digitalimpact says

I guess you’re welcome…

Be more specific on what approach you’re looking for, so people know what to tell you…

1179 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 6-7 years
mabuc says

thanks digitalimpact I want to add span in the wp-pagenavi plugin and I dont want to edit from the plugin file..

default is this
<a href="http://localhost/Wordpress/?paged=2" class="page">2</a>
I want to change it to this
<a href="http://localhost/Wordpress/?paged=2" class="page"><span>2</span></a>
because I am using a rounded gradient button.

thanks…

2444 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
digitalimpact says

Well then, what exactly would stop you to use the solution I posted earlier? (I thought you don’t want to use jQuery for it)

It’s not hard, here goes (not tested, just off the top of my head)


//Wrap it in a span with a predefined class
$('a.page').wrap('<span class="whatever">');
// will result in <a href="..." class="page"><span class="whatever">2</span></a>
</span>

//wrap it in a span with an auto generated class
$('a.page').wrap(function() {
  return '<span class="'page- + $(this).text() + '">';
});
// will result in <a href="..." class="page"><span class="page-2">2</span></a>
</span>

EDIT : I know it won’t work; it will wrap the whole anchor tag; you need to use $(this).html(); will post an updated version – sorry! :)

1179 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 6-7 years
mabuc says

it wont work mate ;)

//Wrap it in a span with a predefined class
$('a.page').wrap('<span class="whatever">');
// will result in <span class="whatever"><a href="..." class="page">2</a></span>
</span>
441 posts Don't be a HATER!
  • Exclusive Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Won a Competition
  • Repeatedly helped protect Envato Market against copyright violations
  • Has been a member for 4-5 years
webinpixels says

you’re use wp-pagenavi as plugin or integrated the script with your theme?

if you’re integrated wp-pagenavi with your theme i think you can simply edit the PHP function :)

1179 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 6-7 years
mabuc says

I just want to replace or override this function in the plugin file core.php

function _wp_pagenavi_single( $page, $class, $raw_text, $format = '%PAGE_NUMBER%' ) {
    if ( empty( $raw_text ) )
        return '';

    $text = str_replace( $format, number_format_i18n( $page ), $raw_text );

    return "<a href="\" . esc_url( get_pagenum_link( $page ) ) . \"" class="$class">$text</a>";
}

I want to add the span tag between

class='$class'>$text
to this
class='$class'><span>$text</span>

and I want to put in my functions.php

441 posts Don't be a HATER!
  • Exclusive Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Won a Competition
  • Repeatedly helped protect Envato Market against copyright violations
  • Has been a member for 4-5 years
webinpixels says

   return "<a href="\" . esc_url( get_pagenum_link( $page ) ) . \"" class="$class"><span>$text</span></a>";

do you mean like that.. :D

or same like digital mention above, you can use jQuery, i think you can wrap the pagenavi function with a div (with a special id),

<div id="special_id">
    &lt;?php wp_pagenavi(); ?&gt;
</div>

then do the trick with jQuery


var pagenavi_a = $('#special_id').find('a');

pagenavi_a.each(function(){
  var pagenavi_text = $(this).text();

  $(this).html("<span>"+pagenavi_text+"</span>");
});

maybe it works :D

good luck

by
by
by
by
by
by