First, you should check if the user is logged in – use is_user_logged_in().
Next step is to get ID of current user with get_current_user_id().
Next, get the URL for the author with the given ID using get_author_posts_url().
The last step is to display the button with the link.
if ( is_user_logged_in() )
{
$uid = get_current_user_id();
$link = get_author_posts_url( $uid );
printf( '<div><a href="https://wordpress.stackexchange.com/questions/344300/%s">My posts</a></div>', $link );
}
You can insert such a code in the header.php
file or add it as a function to functions.php
file and call this function in the header.php
.
Related Posts:
- append url parameters to all links
- How do I retain url parameters the entire time a user browses my site?
- Rewrite custom post type URL parameters
- Append a parametter at first or last to a certain URL
- How do I rewrite URL that has custom parameter
- Get parameters and custom page template
- Custom URL segment parameters for posts
- How to create a front end user profile with a friendly permalink
- Using custom/dynamic “slug” for a page
- How to make pages slug have priority over any other taxonomies like custom-post, post or category
- How do I remove a rewrite rule?
- Rewrite URL – how to do a SEO-friendly Unicode custom URL?
- Can I call a custom plugin with a direct URL
- Custom slug in front of search URL
- Using WordPress with Apache behind an nginx reverse proxy
- How do i change the search permanent links
- add_rewrite_rule() not playing nice with child pages
- rewrite_rule() not preserving the query string
- Appending numbers to url do not break the link
- How to Change Author Posts URL
- Change Attachment Post URLs to File URLs
- WordPress 404 unless there is a space in url
- Change permalink for default archive – yearly
- Add .html extension to only one page in my WordPress site
- How to get “extended” path info from URL in a plugin
- Custom URL routing based on cookie value
- Rewriting rules: difference between ‘init’, ‘rewrite_rules_array’, ‘generate_rewrite_rules’?
- How to perform a query at the URL?
- url rewriting for most recent post
- Is there a way to create alias without using htacess, permalinks or delving into code?
- Remove Query String from URL on Redirect – Redirection Plugin
- Cleanup URL for a custom page in wordpress
- Use custom template on certain URLs
- Rewrite Rules Are Redirecting and Not Passing VARs
- WordPress rewrite rules don’t need ^?
- custom template rewrite
- add_rewrite_rule fro html to another url not working
- Adding rewrite rules directly to .htaccess file
- How to rewrite url wordpress?
- WordPress Redirecting Non Category Pages /page/nnn to their Canonical URLs
- How to create a profile page for specfic / custom user role members?
- I want to add a new tag to WordPress URL permastruct
- How to remove trailing slash from root WordPress folder?
- Rewriting the URL of a custom post to a certain page
- QSA Rewrite Rule
- Persist url parameter passed by a referrer website? [duplicate]
- htaccess rewrite ignored
- URL renaming issue
- Trouble with question mark in rewrite rule
- Redirect htaccess [closed]
- virtual page using url parameters to solve facebook sharing issues
- Why when I enter bad url wordpress doesn’t return error 404
- How would I get WordPress to parse /mypage/area/value as /mypage/?area=value?
- What URL rewriting rule should I write to retrieve a var in the URL?
- Weird characters behind every single link and images
- How to mask url of a specific page without affecting seo [closed]
- How are rewrite rules applied in WordPress?
- Adding Theme File for Non-WordPress Content
- How to pass username in affiliate link in wordpress website
- Show index.php template instead of 404 page template
- URL rewriting in wordpress using parameters
- Rewrite rules – page does not exist
- WordPress rewrite front page url
- URL structure for dynamic content broken since upgrade to 5.8
- Have unique URLs on the ad site
- Redirect users with “.” (dot) in their username and replace with “-” (dash) to correct profile
- WordPress dynamic page handle in theme
- Rewrite htacess rule doesn’t work
- I have a problem with WP_Rewrite
- URL of Website Changed by itself
- How to create dynamic URLs on WordPress?
- ../../page-name backend links are not rewritten
- 404 Rest Route not found – when serving behind “proxy”
- Rewrite Rules are Redirecting
- Change author base and slug in author link
- Rewrite rule not working, suspect redirect string
- WordPress index in subdirectory, blogposts in root directory
- Fresh install redirects to www, breaking page loads
- Rewrite Url using .htaccess or hook
- url restructure or rewrite having $_GET variables
- How to use a RewriteRule to change endpoint url
- taxonomy term in URL slug won’t forward to the correct term for custom post like it does for default categories/normal posts
- Error 404 wordpress redirecting URL
- I want to add one extra field to my URLs, I’m using Rewrite functions but it doesn’t work
- .htaccess RewriteRule to include post type and taxonomy
- What’s the best approach to do this?
- Font Page overrides rewrites
- WordPress Rewrite: Ignore Specific Pattern
- rewrite rule for home/index page
- WPNetwork with custom URL Rewrite rules
- Stop wordpress to redirecting home page if no page found
- Additional .htaccess rules based on wp page
- URL Rewriting in WordPress
- Rewrite URL variable to custom path
- Own code on index.php wordpress theme file, help with the rewrite rules
- URL rewrites af
- How to change search url produced by ‘s GET method?
- Hide / rewrite download link
- Wrong rewrite rules
- Problems Implementing Non-WordPress Rewrite Rules