Store the_title() in a variable

The wordpress function the_title() automatically echos the content to the screen.

Sometimes you want to store this value in a variable.

In this case use:


$string = get_the_title();

One thought on “Store the_title() in a variable”

Leave a Reply