Mauricio Villa asked
php
wordpress
php
wordpress
I dont know If I can explain myself properly but I want to get the title but without something, for example:
The title is: “Recipie: Orange Juice” and I get it with this
<?php the_title(); ?>
And I want to get just “Orange Juice” Is it possible?
Answer
The proper way to do this:
<?php
// Get the title.
$title = get_the_title();
// Replace leading prefix and colon if one exists.
$title = preg_replace('/^[^:]+:s*/', '', $title);
// Output the title.
echo $title;