WordPress.org

Ready to get started?Download WordPress

Forums

Now Reading Reloaded
Page title isn't being populated (2 posts)

  1. brelson
    Member
    Posted 3 years ago #

    My Now Reading Reloaded pages aren't populating the WordPress page title properly. wp_title is blank, and when I try to call nr_page_title on any of the library pages it seems to be blank too.

    Here is the code for page title in my theme's header.php:
    <title><?php if(is_home()) bloginfo('name'); else { wp_title(''); ?> > <?php bloginfo('name'); } ?></title>

    And within now_reading.php there's the function:
    function nr_page_title( $title )

    I won't post the whole function, but I haven't modified it. My understanding is that this function should be populating wp_title, but it doesn't seem to be. And even when I try to call it directly in a page, it seems to be blank.

    I've had Now Reading Reloaded running for some time but have never managed to crack this particular problem. I'm hoping someone here can help and that it's a fairly obvious solution that I'm missing!

    My Now Reading Reloaded site is at http://www.brelson.com/library/

    http://wordpress.org/extend/plugins/now-reading-reloaded/

  2. brelson
    Member
    Posted 3 years ago #

    I've managed to fix this now. The problem lies with the nr_page_title() function in now-reading.php. I was able to resolve it by looking at the code for Now Watching so credit is due to that plugin's author.

    If you have the same issue, the simplest thing to is to replace nr_page_title() in now-reading.php with the code below:

    function nr_page_title( $title ) {
        global $wp, $wp_query, $wpdb;
        $wp->parse_request();
    
        $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 '';
    
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic