Support » Fixing WordPress » Bug in wp_title?

  • I have been trying to run this code in one of my templates in Suffusion, a Page of Posts:

    $page_title = wp_title('', false);
    if ($page_title == '') {
    	$page_title = get_bloginfo('name');

    But this always gives me a NOTICE:
    Notice: Trying to get property of non-object in C:\Users\sasinha\Documents\Downloads\HomePage\aquoid\wp\wp-includes\general-template.php on line 588
    I am not sure why this is happening. Here is what I am trying to do:
    1. I have a “Page of Posts” template. I have chosen to display a list of posts on that page.
    2. Since a list is being displayed, the logic I have is to show either the name of the category / tag / date etc. if one of those objects is being displayed, otherwise pull up the name of the blog itself.

    The code works fine for archives (e.g. category.php, date.php, tag.php etc), but on the single page for posts it fails. I took a look at general-template.php and this is the code there:

    // If there is a post
    	if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
    		$post = $wp_query->get_queried_object();
    		$title = apply_filters( 'single_post_title', $post->post_title );

    The line calling apply_filters is failing. Is this a bug within WP or do I need to ensure something from my end?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m having the same trouble on a recent install on a development server. Did you ever find a resolution to this issue?




    Forum Moderator

    This is an old topic referencing an earlier version of WordPress. Please post a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug in wp_title?’ is closed to new replies.