• Hello everyone,

    I think I know that I need to explode an item but I’m not sure how. I would like to add a name=”” element to an anchor tag but not sure how to add it to my script.

    I’m thinking I need to explode this line:
    $output .= _wp_link_page( $i );

    Could someone point me in the right direction?

    Thank for looking,
    Sam

    This is my script:

    function custom_wp_link_pages($args = ''){
    $defaults = array(
    'before' => '<ol class="wp-paginate">' . "\n",
    'after' => "\n" . '</ol>',
    /*'text_before' => '<li>',
    'text_after' => '</li>',*/
    'next_or_number' => 'number',
    'nextpagelink' => __('Next page'),
    'previouspagelink' => __('Previous page'),
    'pagelink' => '%',
    'echo' => 1
    );
    
    $r = wp_parse_args($args, $defaults);
    $r = apply_filters('wp_link_pages_args', $r);
    extract($r, EXTR_SKIP);
    
    global $page, $numpages, $multipage, $more, $pagenow;
    
    $output = '';
    if ($multipage){
    if ('number' == $next_or_number){
    $output .= $before;
    for ($i = 1; $i < ($numpages + 1); $i = $i + 1){
    $j = str_replace('%', $i, $pagelink);
    $output .= '<li>';
    if ($i != $page || ((!$more) && ($page == 1)))
    $output .= _wp_link_page( $i );
    else
    $output .= '<span class="page current">';
    $output .= $text_before;
    $output .= $j;
    $output .= $text_after;
    if ($i != $page || ((!$more) && ($page == 1)))
    $output .= '</a></li>' . "\n";
    else
    $output .= '</span>';}
    $output .= $after;}
    else{
    if ($more){
    $output .= $before;
    $i = $page - 1;
    if ($i && $more){
    $output .= $text_before;
    $output .= _wp_link_page($i);
    $output .= '</a></li>' . "\n";
    echo "\n";
    $output .= $previouspagelink;
    $output .= $text_after;}
    $i = $page + 1;
    if ($i <= $numpages && $more){
    $output .= $text_before;
    $output .= _wp_link_page($i);
    $output .= '</a></li>' . "\n";
    echo "\n";
    $output .= $nextpagelink;
    $output .= $text_after;}
    $output .= $after;}
    }
    }
    if ($echo)
    echo $output;
    return $output;}
  • The topic ‘Explode anchor tag’ is closed to new replies.