React WordPress Hooks
Edit page
About
Context
Hooks
Block RendererBlock RevisionsBlocksCategoriesCommentsMediaPage RevisionsPagesPost RevisionsPostsPostsSearchSettingsStatusesTagsTaxonomiesThemesTypesUsersWordPress

Posts

usePosts

Available options

Default query (latest 10 posts):

const { data, loading, error } = usePosts();

Posts meeting the criteria:

const { data, loading, error } = usePosts({
/* WordPress REST API options */
});

Single post (by id):

const { data, loading, error } = usePosts(/* post id */);

Multiple posts (by id):

const { data, loading, error } = usePosts(/* array of post ids */);

useCreatePost

Available options

const { data, loading, error } = useCreatePost({
/* WordPress REST API options */
});

useRetrievePost

Available options

const { data, loading, error } = useRetrievePost({
/* WordPress REST API options */
});

useUpdatePost

Available options

const { data, loading, error } = useUpdatePost({
/* WordPress REST API options */
});

useDeletePost

Available options

const { data, loading, error } = useDeletePost(
/* post id */,
{ /* WordPress REST API options */ }
);