I need to pass a variable inside the permalink that takes me to my custom post, and then execute the $_GET
of this variable inside an input of my cf7.
The only problem WordPress encodes the &
in #038;
I tried to decode the special characters but nothing.
Browsing the net, I found on another question here on stackoverflow, the possibility of using: html_entity_decode
But if I echo in frontend, it works perfectly, but when I click on the link it is converted back to: #038;
example:
<?php
$url="?r=".$prezzo_finale.html_entity_decode('&').'s=".$art_p;
echo $url;
?>
return me in frontend with echo: ?r=405&s=Sito Web
but when i click on my post the permalink is: /?r=405#038;s=Sito%20Web
To pass the variable inside my post I use this structure:
<div class="card" id="professionista<?= $query->post->ID ?>" style="cursor: pointer;">
<!-- CODE -->
<script type="text/javascript">
document.getElementById("professionista<?= $query->post->ID ?>").setAttribute("onclick', 'location.href = "<?php echo esc_url( get_permalink($query->post->ID).$url ); ?>"');
</script>
</div>
How can I get this converted?