You are passing the array for post_status
wrong way, Here I updated your code with correction.
To show List of pages
//To display list of pages
$args = array('post_status' => array('drafts', 'publish'));
$pages = get_pages($args);
foreach ( $pages as $page ) {
// some html code that displays the page title
}
To show List of Posts
// To display list of posts
global $post;
$args2 = array('numberposts' => 50, 'post_status' => array('drafts', 'publish'));
$myposts = get_posts( $args2 );
foreach( $myposts as $post ) {
setup_postdata($post);
//... some HTML code to display the pages
}
Note –
It appears you’ve got confused with terms
posts
andpages
.
get_pages()
function will return the pages, not the postsget_posts()
function will return the posts
Related Posts:
- This page didn’t load Google Maps correctly. See the JavaScript console for technical details
- This page didn’t load Google Maps correctly. See the JavaScript console for technical details
- Constructing requests with URL Query String in Python
- Postman Resolving “Invalid CORS request” for a POST Request
- WordPress Rest API custom endpoint optional param
- WP function/filter for modifying http headers?
- Create API for single sign-on with 3rd party site
- Set up WP Authentication from External API
- How do I cache (core) API requests?
- Slow REST API calls on self-hosted WordPress [closed]
- WordPress JSON output
- how to authenticate for the REST API from a plugin and from command line
- External WordPress API
- WordPress API – Get Drafts
- How to stop WP API endpoint from caching?
- How to implement ERP (Enterprise Resource Planning) into WordPress?
- API integration with WordPress
- POST to a REST API from a wordpress form
- Gutenberg internal page link search box
- get WP-API by page id
- Sync posts from one WordPress site to another
- Passing variables to new page
- Developing Themes with React/Angular
- WordPress API – count posts
- API in numbers?
- Does WordPress support a shortcode calling itself from within a shortcode call?
- Stuck with wp_remote_post sending data to an external api on user registration
- API for Post Stats for Self-Hosted WordPress using JetPack [closed]
- Create post with REST API in php with file_get_contents
- How to get WordPress Plugins Data in PHP using Plugin API?
- Displaying Content with WP Rest API
- How to integrate Yelp API
- Where to find WordPress API changes for each version released
- Custom Post for Locating by Google Maps API
- How to Increase WordPress JSON API Speed?
- How can I cache WordPress Rest API Response
- WordPress REST API always misses parameters – rest_missing_callback_param
- Unable to find API Key for my blog
- Why aren’t tags and categories added in post request to WP Rest API
- get_option() fails to return binary result
- Integrate ZOHO Recruit API?
- POST request not going through?
- Allow logged in WordPress user to access 3rd party Laravel API via OAuth
- How can I send edits to my blog programmaticly?
- How to add custom preview urls for some pages?
- Mixcloud FooterWidget api errors in Chrome and Safari but not Firefox?
- wordpress “rest_invalid_handler” error
- WC REST Payment – Stripe Gateway’ is not available
- PHP to Handle API Return instead of print
- How do I query my WordPress posts on another HTML page using the WordPress Restful API?
- Best way to integrate contact us page with wordpress REST API [closed]
- Theme Customizer API Live Preview
- Manage a resource via REST API
- How to query WordPress from another application?
- How to edit feature image with XML RPC?
- Integrate product feed API in Woocommerce [closed]
- WordPress keeps autoplaying my Youtube-Links no matter what I write
- Accessing a 3rd party API – terminology to differentiate between that and publishing an API?
- How to fix AWS SNS API end point code that cause site not to load?
- Integrating API in to WordPress
- WP REST API and Access-Control-Allow-Origin
- Creating posts from API data, how to identify posts already imported?
- Soundcloud Smart Player
- Use WordPress user database in external php application
- Jetpack JSON API configure button not showing [closed]
- Theme Customization API Changes not Saving
- New Twitter API and Twitter count + timeline doesn’t work anymore [closed]
- wp_signon returns user but the user is not logged in because wp installed on subdomain. How to make it work?
- hybridauth (google OAuth integration) and WP problems
- Working Around rest_forbidden_context
- How to queue API requests with PHP in WordPress?
- How to store API authentication password?
- WordPress and API (rapidapi) request
- Post content in wp_remote_post
- I need some assistance opening a few videos in VLC on android automatically from my wordpress site
- Call external API
- Get total count of records in WP GraphQL API
- Intergrate JSON into wordpress
- WordPress json rest api displaying 10 categories only
- Creating posts, containing data from remote API
- Passing data outside of WordPress possible?
- Gravit Forms Notification send after 3rd party API response
- Periodically Query an external API on wordpress site
- Post to WordPress API using cURL and login cookies
- Extending the API I created to return category names
- Expand author, tags and categories in the WordPress JSON API
- How to display parent category with first level child in REST API
- Best way to make a JSON API from WordPress?
- Encrypt API key [duplicate]
- Can I get the post id when trying to make a new post using xmlrpc?
- Using PHP Api wrapper within plugin. Wrapper uses name space
- Querying Posts Using JSON API
- basic wordpress api endpoint to serve a key-value dictionary
- Trying to integrate wordpress query on other website – getting redirection to wp-install
- Is it possible to make website content available on another website?
- How to login via wordpress api and get user details?
- Zoho subscription API to WordPress [closed]
- How many users/load can the rest API handle?
- How get JSON from external API on every page load if not existing in transient?
- Send PUT remote request with BuddyPress checkbox