PHP数组中URL变量的使用(与wordpress相关)

PHP数组中URL变量的使用(与wordpress相关),php,arrays,wordpress,url,variables,Php,Arrays,Wordpress,Url,Variables,我被这个棘手的问题弄疯了。我的url是:www.mysite.com/page/?id=sun 我想获取变量(sun)并将其放入我的PHP数组中: <?php $tag = $_GET['id']; wp_reset_query(); query_posts(array('post_type'=> 'projects','technologiestags'=> $tag) ); if(have_posts()): while(have_posts()):the_

我被这个棘手的问题弄疯了。我的url是:www.mysite.com/page/?id=sun

我想获取变量(sun)并将其放入我的PHP数组中:

<?php 
 $tag = $_GET['id'];

 wp_reset_query();

 query_posts(array('post_type'=> 'projects','technologiestags'=> $tag) );
 if(have_posts()):
 while(have_posts()):the_post();
 ?>

 <div class="technology">
 <h4><?php the_title(); ?></h4><br/><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(''); ?></a>

</br></br><div class="readmore"><a href="<?php the_permalink(); ?>">Read more&nbsp;&raquo;</a></div>

</div><!--END of technology Id-->

<?php endwhile; endif; wp_reset_query();?>




如您所见,我使用了“.echo”$tag“”,但它不起作用。是否有其他方法可以获取URL变量并将其插入PHP


提前感谢。

$tag是一个变量,可以用来代替传递字符串:

query_posts(array('post_type'=> 'projects','technologiestags' => $tag);
query_posts(array('post_type'=> 'projects','technologiestags' => $tag);
如果要进行某些更改,请尝试:

if(isset($_GET['id'])):
        $tag = stript_tags($_GET['id']);
        wp_reset_query();
        query_posts(array(
                'post_type'=> 'projects',
                'technologiestags'=> $tag)
        );
        if(have_posts()):
            while(have_posts()):
                the_post();
                ?>
                <div class="technology">
                    <h4><?= the_title(); ?></h4>
                    <div class="post-title"><a href="<?php the_permalink(); ?>"><?= the_post_thumbnail(''); ?></a></div>
                    <div class="readmore"><a href="<?= the_permalink(); ?>">Read more&nbsp;&raquo;</a></div>
                </div>
                <?
            endwhile;
            wp_reset_query();
        endif;
    endif;
if(isset($\u GET['id']):
$tag=stript_标记($_GET['id']);
wp_reset_query();
查询职位(数组)(
“post_type”=>“projects”,
'technologiestags'=>$tag)
);
如果(have_posts()):
while(have_posts()):
_post();
?>

非常感谢,还是不走运。得到一个错误:Parse error:syntax error,意外的T_变量,在/home/public_html/wp content/plugins/wp php widget/wp php widget.php(52):eval()'d第7行的代码只需在分号之前添加另一个右括号来消除错误。如果这确实是完整的源代码,请记住
If():
while():
(冒号符号)需要关闭<代码>附录> /代码> />代码>结尾/<代码>语句。如果您真的想要一个语句体,请删除Calon。HyLaZZ,完整代码是:


呃,非常有用。请考虑在您的问题中编辑它。对不起,我已经把完整的代码添加到顶部的主问题框中……嗨,NeoMacuser,不幸的是,我没有得到任何运气-错误是:解析错误:语法错误,意外的T_变量,预期为“')”