Found! This function returns the specified fields for each post.
function get_all ( $params ){
$posts = get_posts( array(
'offset' => 0,
'post_status' => 'publish'
) );
if ( empty( $posts ) ) {
return null;
}
$posts_data = array();
foreach( $posts as $post ) {
$posts_data[] = (object) array(
'id' => $post->ID,
'date' => $post->post_date,
'date_gmt' => $post->post_date_gmt,
'modified' => $post->post_modified,
'title' => $post->post_title,
'content' => $post->post_content,
'category' => get_the_category_by_ID($post->post_category[0]),
'link' => get_permalink($post),
);
}
return $posts_data;
}
Related Posts:
- Callback API for getting response from fygaro payment gateway
- How to call a REST endpoint when a post is published?
- How to check if which hook triggered the call to a function?
- Rest API Hook When Post Is Requested
- Extend Woocommerce rest api routes fails
- How can I set status=’publish’ for all featured images?
- Hook before posting via JSON REST API
- How can I count post views of REST API calls and update them in an ACF field?
- `rest_user_query` can’t access post author in post edit screen
- admin_notices action doesn’t trigger within save_post action
- How to get product information using hooks?
- Where can I find a list of WordPress hooks?
- Whats worth using add_action when we can simply use add_filter?
- add_action(‘wp_ajax_[action name]’, myfunction) problem
- Hook on trash post
- Adding onload to body
- What is the earliest possible hook for safely using `is_front_page`?
- Send data to 3rd party api with wp_remote_post on wp_login
- How to customize the WP admin default help contents
- Hide gutenberg option blocks
- admin_post hook not called
- deactivated_plugin hook: get the name of the plugin
- Setcookie works on admin but not front end
- Bulk action hook for admin pages which uses WP_List_Table
- How to hook into user registration process Before user registers
- WP Admin Bar frontend issue with dashicon deregister
- A good way to add a different background image for each page?
- Searching a hook which triggers when deleting a post to get all comments
- add_action for lost_password or modify wp-login.php?action=lostpassword
- Add my own function to existing WooCommerce hook
- @wordpress/hooks use to add actions/filters within multiple plugin
- Firing a function AFTER redirect
- How can I customize the upload error message in WordPress?
- WordPress hook that gets featured image from direct URL?
- Why is save_post hook being called twice despite all my efforts?
- What’s hook to use immediately after a user is authentcated [duplicate]
- add_action for unknown custom post types
- How to prevent double execution of do_action statements
- When is the {$new_status}_{$post->post_type} transition hook fired?
- TinyMCE as comment editor – encoding issues
- Hook to change Logout url
- How to exclude a list of specific category in category widget in new post admin screen?
- Method to find a hook
- Understanding WP
- Get post or page id early
- Looking for a hook for post.php
- Executing Arbitrary Code at a Specific URL without Creating a Post or Page?
- Update a costume wp_usermeta key back to 0 every 24hours (time can be specified as needed)
- customize_controls_enqueue_scripts doesn’t fire from within my plugin
- Save User Meta Email Address in Lowercase
- WooCommerce single product page quantity description [closed]
- Execute JavaScript in WordPress Hook
- How to cancel the trash action inside wp_trash_post
- wp_insert_post_data hook should be called before updating db but isn’t
- What is the difference between add_action and add_filter [duplicate]
- load-* hook for dashboard
- What conditions must be met in order to upload .zip file to a multisite WordPress installation?
- How to hook code in ?
- Is it possible to add the_content filter upon login?
- Use an array of page template slugs and $hook
- wp_logout hook never triggered
- add short description under price
- How do I use pre_option_{option_name} correctly?
- post.php AJAX request not being called when publishing post
- WordPress media library allow uploading fake file
- What hook do I use if I want to update a user profile field when a new user is created?
- How to add custom tab page in backend?
- Add html code in admin page
- What hook to add at start of WordPress load
- Knowing if a post is sticky in the ‘save_post’ action. Where do I have to hook?
- WP_Query retuning empty array in rest api
- How to read and write session data?
- Count when a post of a custom post type is deleted and store it in a theme option
- Can we change the hook firing sequence?
- Add content in cpt archive page
- Creating custom post on registration in wordpress?
- Display custom user profile fields in wordpress
- profile_update not supplying old data
- Output Redirect Headers on Admin Dashboard Page
- How to prevent post update using transition_post_status
- add_image_size not working with after_switch_theme
- wordpress hooks
- Check when a setting has been changed
- is_page not triggering
- admin_post_(action) hook create console log error
- Check if front page within function passed to action
- Hook after creating a post and retrieve infos from this post immediatly
- $new_pass always returns null – password_reset hook
- How to resolve 500 error in post listing page?
- Object oriented programming, add_action in constructor not firing
- Get new (not old) post inside transition_post_status hook
- How to Show Different Information to your authors/contributers
- Cannot override hooks.php
- Removing action from template class
- Remove “enqueued” script from array
- Function is Missing an Action Hook
- How to access variables in the function where apply_filters() is called?
- PHP Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered
- getSaveContent.extraProps hook for core/post-title doesn’t add new attributes on to the frontend
- Changing login url