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 Dynamically Change the author_base URL Slug by Language in WordPress?
- Download images from media library to computer in BULK?
- Define specific category name in PHP
- Can I get an email notification when media is uploaded to the media library?
- PHP Syntax Error on get_posts
- Showing latest post without 301 redirect
- Trying do build a contact form
- Make Current/Active Page Number a Link (WP_LINK_PAGES)
- Convert WordPress date format to jQuery UI Datepicker format
- How to show number of unpublished articles?
- How to make modifications only to certain elements of an HTML string on the server-side?
- “operation successful” message
- WordPress wp_redirect error
- Three Questions with Twenty Eleven theme
- PHP echo inside javascript
- single.php error
- WordPress Theme Modification Help
- Value prints outside of the echo
- RTL Stylesheet Confusion with WordPress
- PHP nested If statement syntax
- WP Insert Post and then go to post
- Non-Closing PHP Query in WordPress Loop
- Translate wordpress date from Italian to English
- How to list posts from a plugin taxonomy?
- Warning: Attempt to read property “ID” on null in D:\xampp\htdocs\yba\wp-content\themes\young-brand-child\functions.php on line 162 [closed]
- Having Issue on Redirecting With Session in WordPress
- Why is $wp->request empty in WordPress 6.0?
- Custom PHP script throws critical error ONLY when editing page