I am building a plugin for WordPress which will communicate with some REST API endpoints and display data in a list format in the public-facing view of WordPress.

Which method I should go for to call the API –

  1. Using wp_remote_get()?

    Pros –

    A. I can give filter and action hook to change the basic HTML layout.

    B. I can use transient to cache data.

    Cons –

    A. It will be slower.

  2. Using AJAX?

    Pros –

    A. It will be much faster.

    B. I can give a function to override to change the basic HTML layout.

    Cons –

    A. Can’t provide WordPress hooks.

Read more here: Plugin development – What method to use to call a REST API?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: