How to get a page url segment on wordpress?

I've created a regular wordpress page named user which is using a custom template.

This page is supposed to be called like so:

www.site.com/user/ID

Is it possible to get the ID segment of the URL programmatically?

The goal is to show the details of the user that belongs to the given ID.

When testing, that part of the URL is always removed.

If I request the URL www.site.com/user/123

the page is redirected to:

www.site.com/user

Thanks in advance.

Topic page-template urls Wordpress parameter

Category Web


yes, you should be able to call the query var by:

get_query_var('user');

if this does not work, then "user" is not the registered query var. You can debug by dumping $wp_query and pin pointing the var / key.

global $wp_query;

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.