Created
June 5, 2024 19:10
-
-
Save zackpyle/2807d56b9f01f937b553e6816dc9bbf6 to your computer and use it in GitHub Desktop.
Get First Name (aka first word in page title)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode( 'first_name', 'get_first_name' ); | |
function get_first_name() { | |
$title = get_the_title(); | |
$full_name_seperate = explode( ' ', $title ); | |
return $full_name_seperate[0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful shortcode (
[first_name]
) when you have a post type of people (team, speakers, etc) and want to be able to use their first name without requiring a separate field to be input