Get value "8" from a wordpress url: mywebsite.com/profile/8/

How can I get that value “8” from a wordpress url: mywebsite.com/profile/8/

    $current_uri = $_SERVER['REQUEST_URI'];
    $url_params = explode( '/', $current_uri );
    $the_value = $url_params[2];

But seems a little dirty to me. Any thoughts? Thank you

NOTE: that “8” changes. Not always “8”.

Read more here: Get value "8" from a wordpress url: mywebsite.com/profile/8/

Leave a Reply

Your email address will not be published. Required fields are marked *