dongnao2048 2016-06-24 21:10
浏览 38

WordPress网址参数无效

What I am trying to do right now is really simple. I want to send a parameter through the URL and then display it on a WordPress page. This is what I am currently doing:

The URL I am putting in is www.domain.com/signin_page?message=yo

The shortcode I added to my functions.php file is:

function write_login_message( $atts) {
  return "Message: " . $_GET['message'];
};
add_shortcode( 'write_message', 'write_login_message' );

The result is "Message: ". Also, I get a notice: Undefined index: message in [...]. I tried something I found in a discussion (making a plugin that sets a query variable) but that didn't work and now I'm stuck. I'd appreciate any help.

UPDATE: $_GET['message'] works on my production server. It isn't working in my test/sandbox server (they are basically the same thing though). This narrows it down, but I am still not certain what the cause is. I can at least move on knowing that I can get it to work on my production server though.

  • 写回答

2条回答 默认 最新

  • doupa2871 2016-06-25 05:47
    关注

    Use this function to create the URL:

    add_query_arg( array(
        'key1' => 'value1',
        'key2' => 'value2',
    ), 'http://example.com' );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题