Replace text in the Title

First things first, lets clean up your code:

<?php $wptitle = the_title(); $wptitle = str_replace('&', 'and', $wptitle);?><?php echo $wptitle; ?>

Lets remove the PHP tag spam and put things in nice clean lines:

<?php
$wptitle = the_title();
$wptitle = str_replace('&', 'and', $wptitle);
echo $wptitle;
?>

Now if we look at the problem, the_title, that function outputs the title and doesn’t return anything. This means $wptitle is empty, so your string replace does nothing.

You need to tell it to return it or it won’t know, computers aren’t the same as people, they need to be told explicitly what to do with no assumptions.

However, a quick google for the_title brings up the codex as the first entry, along with a related function get_the_title which would solve your problem. Reading the documentation says that these are the arguments this function takes:

<?php the_title( $before, $after, $echo ); ?>

So you can change $wptitle = the_title(); to this:

$wptitle = the_title( '','',false );

Or this:

$wptitle = get_the_title();

There is also a much better method that you can use involving filters:

add_filter( 'the_title', 'drabello_swap_ampersands' );
function drabello_swap_ampersands( $old_title ) {
    $new_title = // do the replacement..
    return $new_title;
}