create shortcode that changes url endpoint

I am calling data from an api and looping through it as an array. The problem is that I want to only call one individual profile at a time and have a shortcode for each individual profile. I have created the shortcode function and it does work. However, I have to either call all the profiles in the loop or only one through an if statement. This is obviously not what I want. I want to be able to add: player_number=664 (for example) to the end of the endpoint url. Here is my code as it is right now:

function individualPlayer(){
$html .= ‘<div class=”s-players”>
<div class=”container”>’;

$responseindividualPlayer = wp_remote_get(‘http://api-address-hidden-for-security/statsajax.php?action=rankedplayerslist&eventid=5’);

$array = json_decode(utf8_encode($responseindividualPlayer[‘body’]),TRUE);
foreach($array as $player){
if($player[‘Numero’] == 707) {
$html .= ‘
return $html .'</div></div>’;
add_shortcode(‘individualPlayer’, ‘individualPlayer’);

I want to remove the if statement.
The URL gives the event ID followed by ?player_number= then the player number.

I would love to have it [shortcode ‘player_number=123’] if that is possible. If it is not possible, could someone please help orient me in the right direction?
Thank you in advance.
Erik Robles

Read more here:: create shortcode that changes url endpoint

Leave a Reply

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