Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WP API get all posts
public class WpClient {
public void getListOfBlogPosts(@Observes @Initialized(ApplicationScoped.class) Object object) {
Client client = ClientBuilder.newBuilder().build();
WebTarget webTarget ="");
JsonArray result = webTarget
.queryParam("per_page", 100)
List<String> allBlogPosts = result
.filter(jsonValue -> jsonValue.asJsonObject().getString("link").contains("how"))
.map(jsonValue -> jsonValue.asJsonObject().getJsonObject("title").getString("rendered"))
for (String title :
allBlogPosts) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment