1
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

global $wp_query;

if ( $wp_query->max_num_pages <= 1 )
    return;
?>
<nav class="woocommerce-pagination">
    <?php
        echo paginate_links( apply_filters( 'woocommerce_pagination_args', array(
            'base'         => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ),
            'format'       => '',
            'current'      => max( 1, get_query_var( 'paged' ) ),
            'total'        => $wp_query->max_num_pages,
            'prev_text'    => '&larr;' ,
            'next_text'    => '&rarr;',
            'type'         => 'list',
            'end_size'     => 3,
            'mid_size'     => 3
        ) ) );
    ?> 
</nav>

I need to add Nofollow to the list items generated in this PHP script. How would i go about doing that?

1

A simple str_replace would do the trick:

$links = paginate_links( $arguments );
$links = str_replace( 'href="', 'rel="nofollow" href="', $links );

echo $links;
0

If you want full control over the output you can use the type "array" which will instruct the paginate_links() function to produce and array, then you can do whatever you want with it, see the function documentation.

$links = paginate_links( 
        '...'    => '...',
        '...'    => '...',
        'type'   => 'array',
        '...'    => '...',
        '...'    => '...',
);

foreach( $links as $i => $link ) {
    print_r($link);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.