So I want to create a custom template file for my user profile page something like this URL http://localhost/wordpress/user/username.
Here you can see I have created a new page in Admin with this permalink user
and I have created a new file in my theme directory at theme/user/page-{slug}.php
and below is my code for this file.
<?php
/*
Template Name: User Profile
*/
wp_head();
?>
This is user profile page
<?php wp_footer(); ?>
I have also selected this template file in admin for this page and below is the screenshot of this newly created page.
But when I go to browser and try this URL http://localhost/wordpress/user/company , its giving me "Page Not Found" error.
Can someone guide me what I am doing wrong here ? How can I set a template based on this slug company
here which has user
in the URL.
company
exist in the WordPress posts table, or iscompany
a child of theuser
page? What is "username" - the username of a registered user on your site, or is it just a custom parameter used in your page template? Also, I know/user/username
displays a user profile page, but what would/user/
display?page
andcompany
is just a slug and it wont be in posts table or in any table. Its just a custom parameter./user/
without slug I will check and redirect if without slug.