WordPress / PHP パラメータ引き継ぎ
パラメータ元ページ
<?php
$post_id = get_the_ID();
$post_url = get_permalink();
$prms = '?pid='.$post_id.'&purl='.$post_url;
echo '<a href="' . home_url() . '/test/' . $prms . '">parameter test</a>' . "\n";
?>
パラメータ引き継ぎ先ページ /test/
<?php
// パラメータを取得
$post_id = $_GET["pid"];
$post_url = $_GET["purl"];
?>
<script>
$(function(){
var post_id = '<?php echo $post_id; ?>';
var post_url = '<?php echo $post_url; ?>';
if ( post_id && post_url ) {
// 処理
}
});
</script>