I'm trying to use the Wordpress API (version 1 - not the new Rest API) to retrieve blog posts from various sites. However, I noticed that it was not retrieving the "featured" posts, only normal ones.
The API call I am using is: https://public-api.wordpress.com/rest/v1/sites/$site/posts
Is there a way to retrieve all the posts (normal and featured)?
Thank you!
User tried and confirmed to be working
https://developer.wordpress.com/docs/api/1/get/sites/%24site/posts/
There's a Query Parameter called 'sticky'.
Related
Edit : the thing I was looking for is called Custom Post Type in the WordPress World
Disclaimer: it is my first steps with WordPress and I realize I do not have the right vocabulary to make a proper google search, so please excuse me if this answer has been already asked many times ...
I'm working on a website that use an old preexisting WordPress as headless CMS.
On this new website, I need to display some "job offers"
On the preexisting WordPress, those job offers are just HTML blocks embedded in a page. So I can't get only those without having the embedded page HTML and CSS
If I could have created a custom REST API to get those "job offers", I would have said that those resources would look like this :
{
title : string,
description: string
}
My first idea would be to create a WordPress custom end point, but I do not know if it is possible to create custom entities (entries (?) If I take up the vocabulary of strapi)
Is this something that can be done?
I've tried :
basic google search
reading the strapi and wordpress documentation
I expect to be referred to a solution or to know what to search
The thing you're looking for are Custom post types if that can help a plugin called ACF can help with the custom fields.
I'm using WordPress REST API and can receive data from https://websitename.com/wp-json/wp/v2/posts?_fields=author,id,excerpt,title,link,featured_media_src_url.
The problem is featured_media_src_url is added with This WordPress Plugin and I can't retrieve it using URL filters. (it works by fetching just .../w/v2/posts without params)
It looks like the plugin gets the path using featured_media which returns an id. Adding this to the fields solves the problem:
https://websitename.com/wp-json/wp/v2/posts?_fields=author,id,excerpt,title,link,featured_media_src_url,featured_media
I have a react project which fetches data on wordpress via api calls (plugins installed: ACF and WPML).
I have the Event CPT and viewing the page localhost: 3000 / events / first-event, I retrieve the information via the slug.
If on this page I wanted to retrieve the same event in another language, I could add the country code in the url and make a redirect.
It is possible that the same event has different slugs based on the language and the feature does not work.
Do you have any ideas on how to make this feature?
Thank you guys!
I have temporarily modified the pathname.
<a href={window.location.pathname.replace('/','/en/')}>EN</a>
I have found the solution.
I used the icl_get_languages() function to fetch the languages, icl_object_id() to retrieve the post id of a language, get_post to retrieve all fields and update_post_meta to add a custom field to the post.
Hey I have the same setting but not with React.
If you are using the API without any modifications in the class and given that the title between language is the same try the following:
/wp-json/wp/v2/posts/?post-slug=second+post&lang=fr
and page slug
/wp-json/wp/v2/pages/?page-slug=second+post&lang=fr
However, you need to modify the API response if you want your ACF fields to be there (or use a plugin).
Also mind that post ID between translations is different. Ensure to include the lang as argument in the modification of the WP_REST_Controller. https://developer.wordpress.org/reference/classes/wp_rest_controller/get_collection_params/
Let me know if that helps.
I am displaying an Instagram feed using the Wordpress plugin "Instagram slider widget". Is it possible to show the total post count? how many post this account has posted? using this plugin or using the Instagram API.
You can get the total number of posts for a user with the Instagram API using the GET /users/user-id endpoint.
https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN
The response will include counts of media posted by the user. See https://instagram.com/developer/endpoints/users/#get_users
In Wordpress I have created a custom field 'LatLonPosition' which contains different positions in the following format '48.96N, 10.23W'.
I was wondering if it's possible to pull the custom field content so that it displays a google map on each posts of the coordinates.
I know you can download google map plugins, but I was hoping to do this with the custom field if possible.
Hope someone can help.
Thank heaps
Though i have started working on word-press and php but its quite possible what you are trying to achieve
You can use either
get_post_custom_values()
if you are not concerned with the uniqueness else word-press also provides get_post_meta()
here are the details
Accessing post custom fields