WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
title attribute for links (3 posts)

  1. Surfer92
    Member
    Posted 2 years ago #

    Hi there,

    It would be great if all the links (a-tags) within the page navi (div with class "wp-pagenavi") contained a title attribute, e.g. saying "page 1" or "page 3" etc.

    Maybe there could also be an option to (de)activate it - for those who (don't) like titles. ;)

    Thanks and best regards from Germany, Chris ;)

    http://wordpress.org/extend/plugins/wp-pagenavi/

  2. jrf
    Member
    Posted 1 year ago #

    +1
    Especially as the default prev/next links (ยป) are non-descript without it.

    Obviously localization should be added to the title text as well. May be via the settings panel ?

  3. jrf
    Member
    Posted 1 year ago #

    FYI

    I'm currently using the following code as a temporary solution making use of the echo variable which was added in v2.8.3.
    I've also included the assistive text variable for screen readers (accessibility).

    if( function_exists( 'wp_pagenavi' ) ) {
    	$navi = wp_pagenavi( array( 'echo' => false ) );
    
    	// Add screen reader assistive text
    	// Add title tags to page navigation
    	$patterns = array(
    		'/<div class=[\'"]wp-pagenavi[\'"]>/',
    		'/class=[\'"]first[\'"]/',
    		'/class=[\'"]previouspostslink[\'"]/',
    		'/class=[\'"]nextpostslink[\'"]/',
    		'/class=[\'"]last[\'"]/',
    		'/class=[\'"]page (smaller|larger)[\'"]>([0-9]+)</',
    	);
    	$replacements = array(
    		'<div class="wp-pagenavi">' . "\n\t\t\t\t" . '<h3 class="assistive-text">' . __( 'Post navigation', 'twentyeleven' ) . '</h3>',
    		'title="Go to the first page" class="first"',
    		'title="Go to the previous page" class="previouspostslink"',
    		'title="Go to the next page" class="nextpostslink"',
    		'title="Go to the last page" class="last"',
    		'title="Go to page $2" class="page $1">$2<',
    	);
    	$navi = preg_replace( $patterns, $replacements, $navi );
    
    	// display it
    	echo $navi;
    }

    Hope this helps others running into the same issue.

    Smile,
    Juliette

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic