Передача атрибутов шорткода в WordPress Remote Post URL - PullRequest
1 голос
/ 08 октября 2019

Я пытаюсь передать значения атрибутов шорткода непосредственно в мой URL для запроса WordPress Remote Post. Ниже мой пример кода ниже. Я использую следующий шорткод на своей странице wordpress

[example-data start = "1" count = "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' );
...