1. How to make page titles work properly in Now Reading Reloaded

    Posted May 7, 2011 in How-to  |  9 Comments so far

    I use a plugin called Now Reading Reloaded for the Library section of this site, and very good it is too.

    Unfortunately the developer behind the plugin doesn’t have time to maintain it any more. This means that some things have started to break in newer versions of WordPress, particularly the way the plugin works with page titles. If you’re using Now Reading Reloaded and the title of a book isn’t showing up in your <title> tag, this post should help you fix it.

    The problem is with the file now-reading.php, which you’ll find in the plugin folder. Open this file in a text editor and find the function called nr_page_title(). It starts with the following line:

    function nr_page_title( $title ) {

    This is the function that tells WordPress what to put in the page title, and if you’re having the problem I was having this is where the blame probably lies. To solve the problem you’ll need to replace this function with the one that appears below.

    function nr_page_title( $title ) {
        global $wp, $wp_query, $wpdb;
        $title = '';
        if ( get_query_var('now_reading_library') )
            $title = 'Library';
        if ( get_query_var('now_reading_tag') )
            $title = 'Books tagged with “' . htmlentities(get_query_var('now_reading_tag'), ENT_QUOTES, 'UTF-8') . '”';
    	if ( get_query_var('now_reading_author') ) {
    		$author = $wpdb->escape(urldecode(get_query_var('now_reading_author')));
            $author = $wpdb->get_var("SELECT b_author FROM {$wpdb->prefix}now_reading WHERE b_nice_author = '$author'");
    		$title = 'Books by ' . $author;
        if ( get_query_var('now_reading_search') )
            $title = 'Library Search';
    	if ( get_query_var('now_reading_title') ) {
            $esc_nice_title = $wpdb->escape(urldecode(get_query_var('now_reading_title')));
            $book = get_book($wpdb->get_var("SELECT b_id FROM {$wpdb->prefix}now_reading WHERE b_nice_title = '$esc_nice_title'"));
    		$title = $book->title . ' by ' . $book->author;
        if ( !empty($title) ) {
            $title = apply_filters('now_reading_page_title', $title);
            $separator = apply_filters('now_reading_page_title_separator', ' » ');
            return $title.$separator;
        return '';

    Copy this function and paste it into now-reading.php. To be on the safe side, take a backup of now-reading.php before you do this. Make sure you paste over the entire function – no more, no less.

    If all goes well your page titles should now work if you’re using WordPress 3.0 and above (and if you aren’t, you need to update WordPress right now). If you have any questions, let me know in the comments.

    Note: I was only able to find this fix by reviewing the code of Now Watching, an actively maintained fork of Now Reading Reloaded which handles movies instead of books. The author of Now Watching is Zack Ajmal and he deserves more credit than I do for this fix!