wordpress - 将短代码属性传递给 WordPress 远程发布 URL
问题描述
我正在尝试将简码属性值直接传递到我的 WordPress 远程发布请求的 URL 中。下面是我的代码示例。我在我的 wordpress 页面中使用以下简码
[示例数据开始=“1”计数=“10”]
但我无法让开始或计数数据在 URL 中工作。任何帮助,将不胜感激。
function display_example_data( $atts ) {
$value = shortcode_atts( array(
'start' => 1,
'count' => 10,
), $atts );
$url ="https://example.com/api/reviews?token=".$api_text_key."&start=".$value['start']."&count=".$value['count']."";
$response = wp_remote_post( $url, array(
'method' => 'GET',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'cookies' => array()
)
);
<?php }
add_shortcode( 'example-data', 'display_example_data' );
解决方案
推荐阅读
- codeigniter - 您的服务器不支持处理此类图像所需的 GD 功能。在 Codeigniter 中
- javascript - chrome 扩展的新手:没有按预期工作
- python - Python type() 没有给出确切的类类型,而是给出了元类类型
- python - 为什么 Matplotlib 中的 pyplot 不允许您在显示图像后保存图像?
- angularjs - AngularJS typeahead 指令 - 在选择时获得结果?
- java - 有没有更有效的方法在编译前不知道关键字的情况下在句子中搜索关键字?
- jenkins - 在詹金斯管道中加载 groovy 类
- r - 当我在 r-markdown 中编织时,它会扭曲我的箱线图
- python - openssl verify error:num=20:unable to get local issuer certificate
- c# - 无法使用 Xamarin-iOS 和 ReactiveUI 在 ViewModel 中绑定 UIButton 和 UITextField