Try the following:
<?php
$fname = get_the_author_meta('first_name');
$lname = get_the_author_meta('last_name');
$full_name="";
if( empty($fname)){
$full_name = $lname;
} elseif( empty( $lname )){
$full_name = $fname;
} else {
//both first name and last name are present
$full_name = "{$fname} {$lname}";
}
echo $full_name;
?>
Related Posts:
- Why have on every line
- Function to return true if current page has child pages
- Include a external PHP file into a WordPress Custom Template
- List of all theme customizer control types?
- How to remove hardcoded characters from playlists?
- is there a simple way to list every templates / php files used to generate a specific page?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- Widgets not showing in my custom theme
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- Displaying theme options in css
- Customizer: Output default value in Customizer CSS
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Converting HTML Template to WordPress Theme
- Customizer: active_callback and sanitize_callback incompatibility?
- Menu jumping when calling it via PHP
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- How to obtain the current website URL in my theme?
- What exactly do this function declared into functions.php file of a WP theme?
- Underscore – Self hosted fonts
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Is there a hack for using is_page() within the function.php file?
- pass html code to worpdress
- How to get php file based on URL in WordPress
- How can I customize a WordPress theme before it’s downloaded?
- Where can I find the declaration of `$_wp_theme_features`?
- Display tab title as ‘blog tagline | blog title’
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- How to add button to top of theme customizer?
- PHP unit testing WordPress?
- Cleaning up WordPress to improve performance?
- Show the most popular post per week
- Add a class to links in the visual editor (how to get old dialog back)
- Is having multiple theme customizers for different pages possible?
- function_exists call in function.php
- Debugging an error: wp_enqueue_style was called incorrectly
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- Search and Replace in database: How to replace data in SQL dump file on Windows?
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- Remove css styles from specific page
- Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?
- PHP Customization: Taxonomies and Queries, why? [closed]
- My Own layout in WooCommerce pages [closed]
- Differences when using the the_time and the_date functions
- Change the site tagline (or similar) based on current page
- create a select input with menus created on a custom options page
- Theme Options Page – User Updates Logo
- Can’t access variable outside for loop
- add custom link to wordpress media gallery modal
- How to pick the default selected value in wordpress dropdown?
- Customize position of social icons in upme plugin [closed]
- Two queries for a WP_User_Query search work perfectly apart, but not together
- How to edit widget code to add unique class name to each div?
- Media Upload , file name changed automatically
- Replace shortcode in substring
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- WordPress admin-ajax.php
- Syntax error when I try to insert my loop into an unordered list? [closed]
- Royalty-Free Sliders used in theme development
- Reason to add a name of the theme like (‘menu-1’ => __( ‘Primary’, ‘twentynineteen’ ),) in PHP?
- zip unzip attachments in wordpress
- customize wordpress database error page
- WordPress get_media_embedded
- Ajax search shows all results when user empties input?
- List post by title length
- Need help with pagination
- get_comments_number() returns 0
- Why the dynamic_sidebar() call is putted into an ul tag?
- Toolbar Hidden in a Virtual Page
- Editor capabilities – admin_init
- WP insert post Redirect after function has executed
- Remove Custom Post Category In WordPress Slug Using .Htaccess
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- How can I add diffrent editable text fields?
- Header is not displaying on certain pages of wordpress theme [closed]
- Featured image in menu wordpres
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- Looping through dummy posts and showing them in the main index.php
- Need help transforming echo to return for use with shortcode
- Redirect after login depending on the URL
- Customizer: How to Sanitize a Decimal Number Range
- PHP code printed into CSS classes
- Get the image title and alt from custom query
- What syntax is this? “{{post.price}}”
- Real time notification on user profile after new comment
- How to add text before posts
- Add two or multiple functions in WordPress Post or Page
- WordPress error on my website
- WordPress get_post_meta issue
- Best way to define a database with product codes and back-end support?
- wp_customize_image_control default value
- How can I add more code to this?
- Sidebar doesnt get updated?
- Edit the Publish Widget Options
- ACF | WooCommerce | Theme Development | How to include a /template-part/ that makes use of ACF’s on a custom WooCommerce homepage?
- Predefine Magazine Style Layouts
- Twig+WordPress how to use array arguments inside a function?
- Add multiple HTML attributes to an Elementor button