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!

9 comments so far.  Post a comment

  1. May 10, 2011 at 9:47 pm [ Permalink

    This is really helpful, thanks – that title issue has been bugging me for a while.

    I need to take a day to sort out Now Reading and my own php skills. I’ve still got that styling issue that sends the right-hand nav to the bottom of the page.

    I uploaded your fixes, but no change, then I thought it’s something to do with my blog having a two column theme, but I notice your new design is two columns too…confused. Might give up and go with Goodreads instead.

    Nice new design btw!

  2. May 12, 2011 at 1:01 pm [ Permalink

    Glad you like the design!

    I think I know what’s wrong with your theme – there’s one div with the ID “content” and inside it there’s another div with the CLASS “content”. I’m not 100% sure what effect this is having but I expect this is the thing that Now Reading Reloaded is having problems with.

    If you trust me to meddle with your theme files I’d be happy to fix them for you, it wouldn’t take too long I expect…

  3. May 18, 2011 at 12:35 am [ Permalink

    This change did not work for me. In fact, now the library page is not even opening. I reset the code to the original but I am still getting error “Page not found”.

  4. May 18, 2011 at 12:52 am [ Permalink

    Thank you for the code. I discovered that after changing the code, you need to update settings in library. You can make any change in library and update and this will enable library. Otherwise – page not found.

    I still need to fix some portion of the title but at least title is visible so I can play with it.

  5. May 18, 2011 at 12:55 am [ Permalink

    Are you using the same Now Reading Reloaded plugin? Your books look so neat. How did you do that?

  6. May 18, 2011 at 9:01 am [ Permalink

    Hi Himanshu,

    I’m glad you got the page title fix to work, but sorry that you had problems with the code. Just to check, you got it to work after making any change to the settings in the library’s Manage Books interface? And one more question, are you running any caching plugins like wp-cache? Let me know and I’ll update the instructions in this post.

    As for the way the books are displayed on this site, I am using the same plugin but decided to customise the templates and CSS quite heavily. The plugin doesn’t really look very good when you use it with modern WordPress versions, so it needs a bit of work! I’m thinking of releasing a new version of the plugin optimised for WP 3.x CSS, and will post it here if I ever get around to it!

  7. May 19, 2011 at 12:32 am [ Permalink

    I thought of playing around the settings of library so I enabled debug mode and clicked Update button. Library page opened well. Then I replaced the old code with the new code. Library page was broken again. I found that there was a JavaScript error from wp-minify so I disabled that plugin. Library page was still broken. I clicked Update button in Settings library and the Library page worked. Thus, I found that if you make changes in the now-reading.php then you have to click Update button.

    By the way, I use WP-Supercache and WP-Minify. I just realized that I forgot to enable the innocent wp-minify so I will enable that now.

    Also, I would like to see your css files.

  8. July 9, 2011 at 5:23 am [ Permalink

    Please tell me how you managed to get your library to show on a page?

  9. Himanshu Bansal
    July 9, 2011 at 10:03 pm [ Permalink

    If you mean sidebar coming to the bottom then I checked php code for my single post of theme and noticed that library used

    While library.php was using

    I made library code sync with my theme. I can help you if you write the code here.

RSS feed for comments on this post. TrackBack URL

Leave a comment