WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to get title of viewed page (4 posts)

  1. christian_gnoth
    Member
    Posted 3 years ago #

    I want check with each page request if the page has changed.

    I am using wp_title for it. I am saving the title in a session variable $_SESSION:

    $biq_title = wp_title('',false);
      if ( $biq_title == '' )
        $biq_title = 'Home';
      if ( $_SESSION['biq_last_title'] )
      {
        //  check if page has changed
        $biq_last_title = $biq_title;
        if ( $_SESSION['biq_last_title'] == $biq_last_title )
          return false;
        else
        {
          $_SESSION['biq_last_title'] = $biq_title;
          return true;
        }
      }
      else
        $_SESSION['biq_last_title'] = $biq_title;
    
      return true;

    the session variable looses its value and contains a 'page not found'.

    If the session variable looses its value I would expect a NULL value, but how it gets the 'page not found'????

  2. christian_gnoth
    Member
    Posted 3 years ago #

    any idea how it comes???

    I tried to save the last page title in a wp option. there too the 'Page not found' is saved.

  3. christian_gnoth
    Member
    Posted 3 years ago #

    the wp_title returns the page title as expected and this value is stored successfully in the session variable on return of the function.

    but the next time the function is called the session variable has again the value 'Page not found' runs through the function and has on the end the page title.

  4. christian_gnoth
    Member
    Posted 3 years ago #

    is wp changing the content of session variables???

Topic Closed

This topic has been closed to new replies.

About this Topic