dsceme82487 2014-07-05 04:17
浏览 17
已采纳

wordpress页面中的变量字符串永久链接

I have a page in wordpress which shows all registered users in a table. When clicked on a user you'll be redirected to their user page. Here is a sample:

  1. echo '<tr onclick="location.href=\'/user/'.$slug.'/\'">
  2. <td>'.$result->firstname.' '.$result->lastname.'</td>
  3. </tr>';

Where $slug is retreived from the database. I have a page with permalink

my_wordpress_site.com/user

. So if I click on a user I get redirected to a link

my_wordpress_site.com/user/example_user_slug

Which doesn't show anything because it's obviously a non existent sub page. I've tried something like $_GET in the permalink but wordpress doesn't allow that. How do I fix this?

  • 写回答

1条回答 默认 最新

  • dragonfly9527 2014-07-07 02:32
    关注

    HTML

    <form action="#" method="get">
       User name: <input type="text" name="user"><br>
    
       <input type="submit" value="Submit">
    </form>
    

    PHP

    if($_GET['user'])
    echo $_GET['user']
    

    if you want to build links you can use add_query_arg() in WP or if you want to deal with the params in a array $query = explode('&', $_SERVER['QUERY_STRING']);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部