您可以尝试使用“link\\u before”和“link\\u after”参数来获取某些str\\u replace的句柄;在示例中,我使用了<span>
:
$paged_page_nav = wp_link_pages(
array(
\'before\' =>\'\',
\'after\' => \'\',
\'link_before\' => \'<span>\',
\'link_after\' => \'</span>\',
\'echo\' => false
)
);
// Now let\'s wrap the nav inside <li>-elements
$paged_page_nav = str_replace( \'<a\', \'<li class="\'.$classes.\'"><a\', $paged_page_nav );
$paged_page_nav = str_replace( \'</span></a>\', \'</a></li>\', $paged_page_nav );
$paged_page_nav = str_replace( \'"><span>\', \'">\', $paged_page_nav );
// here I\'d need to wrap the currently displayed page element, which could even get a different class
$paged_page_nav = str_replace( \'<span>\', \'<li class="\'.$classes.\'">\', $paged_page_nav );
$paged_page_nav = str_replace( \'</span>\', \'</li>\', $paged_page_nav );
echo \'<ul>\'.$paged_page_nav.\'</ul>\';