I don’t know what are you trying to do with if-else statement, but to display author name with their published post link use this code:
<span>Article posted by <?php the_author_posts_link(); ?></span>
Tweak it according to your need.
One more thing: You need to call the_author_posts_link() function within the while loop (Yes, the same while loop, which is used to print the_title and the_content).
Related Posts:
- Only get_posts of certain post formats
- the_author_posts_link css class
- How do I get the author’s page url from their ID?
- Current post’s author name in the author meta tag
- Allow authors to post only in categories they create in WordPress
- Archive listing of posts by publish year (multiple years)
- Missing Author Information
- Archive dropdown styling not applied
- Get_the_author doesn’t return author name
- the_author() not working outside the loop
- Use is_product_category() properly
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- How Can I Call Up The Author’s Name on a Post
- How to query for pages/post depending on slug?
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Retrieving Author ID in wp-admin area
- Global variable $post returning incorrect object
- Storing Array from returned database query and using the array in a new query
- Show full posts in archive
- What is an equivalent of single_cat_title for getting the slug of the category?
- edit_comment_link is not showing for comment author
- wordpress archive a user
- Remove author link wherever author’s name is display
- Using Shortcode to Grab Archive Listing, Separate by Year
- How do I remove a category from a wordpress loop>
- Noindex Posts From Certain Authors In WordPress
- Issue with custom loop in Archive page
- Noindex subscriber author page
- How to hide the author box of a specific user?
- How to Fix an Archive.php That Displays All Posts?
- First post article different on Archives template
- Comment_author_url doing nothing
- Blog suddenly shows Archive instead of index page
- Create condition for Author bio Social Links
- How to change the author box selection on a post to a custom taxonomy
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Remove Author Links
- WordPress redirect to a subpage – how to create a template for subpage?
- Displaying the Archive Page’s Name on the Page
- Show all people who commented on all posts by an author
- Display WordPress archive template page in 3 columns and not 1 column [closed]
- Show sidebar only to author of post
- Posts missing on author page
- Exclude category from function – PHP
- Link to index.php from home.php?
- Return author name as a tag using get_author
- Permalink like example.com/taxonomy/post_type/postname
- Send Notification to all users that followed some author
- Following/Followers Users list Using Ajax Pagination inside Author Profile
- Send email to users when they get new followers
- How to tell if a page has subpages for Custom Post Types
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- How to make a parent page for author.php?
- How to add custom text near category/tag title in WordPress Twenty Fifteen Theme?
- Display tag links on archive page?
- Changing WordPress author name in database
- Showing the authors username and bio on custom author.php
- How can I output the slug of a comment author?
- Weird slug in archives permalink
- Archive page if else not working for post_excerpt and post_content
- Page 2+ of taxonomy archives does not recognise sort-order from dropdown
- How to have Function of a plugin using global vars into a shortcode?
- dynamically filter by category via sub-menu
- When I use rewind_post() it shows menu items in my loop
- Custom Archive Page
- Hide empty categories from get_categories
- WordPress categories not working throughout site
- archive per year with monthly
- Custom archives page by month and year – nesting problem
- Assign new post author IF another user in custom field on post transition
- Create guest author page via php
- Adding commas between post titles on an archive page?
- How to get user by display_name with WP_User_Query
- Changing Link Attributes for Wp_Link_Pages
- Unusable menus and “Illegal widget setting ID: nav_menu_item[]” error
- Passing POST data from one WP post to another
- Call to undefined function issue
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- How can I generate random numbers inside my shortcodes on each implementation?
- WordPress automatically adding html tag around PHP code
- Converting HTML Template to WordPress Theme
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- Woocommerce hook run after an Order been created through REST API
- Flexslider won’t work on WordPress
- Unable to Find Space in Custom Function
- How do I make this Metabox show current DB value?
- Is there a (offical) way for a theme to deactivate itself and show a message in admin?
- Trying to load category thumbnails on wordpress page
- Retrieve alt text by referencing the img src
- var_dump() and print_r() display null in php
- Delete post meta by serialized meta value
- Create a temporal post
- How can I copy an ACF field to AIOSEO field? [closed]
- Modify arguments for parent theme’s `wp_register_style` via child theme
- WordPress Rewrite Issue
- How to Publish WP original Source metabox value on front-end webpage
- How to wrap a text with shortcode into php file?
- WP Custom tables query
- External WP_Query call from PHP crashed after version update
- WordPress post-template null warnings