2

I'm rather new in Wordpress developing and here is what I'm trying to do.

I've developed a plugin that retrieves and displays a very few details from JSON objects on a Wordpress page via a shortcode, a kind of list. I want to get more details from each item in the list on a single page when clicking on the items. So that I can get a dynamic page which could display more data from every single object of the list through a get parameter. The get parameter would be the object ID so that I can query it from my JSON source. I don't know if I make myself clear =/

How can I achieve this?

Thanks

1
  • @Piere Could you please share your repo link for the solutions you achieved for this? Jun 17 at 13:57
0

You need javascript code that make ajax request (after click on item from list) and display data from response.
You will need also function that receive object ID from request and prepare response. Add function to action hook wp_ajax_nopriv_my_action

add_action( 'wp_ajax_nopriv_my_action', 'my_action' );

function my_action() {
    $output = '';
    if ( isset($_POST['object_id'] ) {

       // prepare output
    }
    echo json_encode($output);
    wp_die();
}

ajax in WP

1
  • Thanks, for your reply. I've eventually made it through query_vars.
    – Pierre
    Aug 1 '18 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.