Each post is an object, which changes the syntax you need to use to access the post name:
$arr = get_posts();
$arr = array_reverse($arr);
foreach ($arr as $post) {
echo $post->post_name;
echo "<br/>";
}
As a side point, a slightly easier (and computationally more efficient) way to get your posts in reverse order is to use this instead of array_reverse()
$arr = get_posts(array('order'=>'ASC'));
More fun things you can do with get_posts()’s arguments can be found here and here.
Related Posts:
- Only get_posts of certain post formats
- Is the first item returned by get_posts() always the latest post?
- Why can I not use setup_postdata($post) in the sidebar?
- Getting movie and serial on actor page
- how to display active, upcoming and past event with featured listing with pagination
- Display 4 chronological posts starting with a random post
- How do I output a database option that is an array into a get_posts array?
- Advanced Custom Fields: Post Object – Not returning data [closed]
- Why not yield/iterable in posts interface?
- Logged in user ID as post ID
- How do I exclude recent post from recent post php widget
- Open post-content in archive page in a Modal box with bootstrap
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Query if audio attachment AND/OR custom field
- How do I get post attachments in menu_order in WordPress?
- PHP Syntax Error on get_posts
- How i can get post data from database when i am getting post id from url in wordpress
- How to retrive the text : No movie by this actor
- How to get image from url from the database?
- Unable to render custom field after attempt to generate a list of recent post in page template
- Add class to every other posts using get_posts
- search.php to search only the post title
- How to get woocommerce orders with get_posts method in a shortcode
- get value from get_post_meta then reuse it in another get_post_meta
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- How can I render more than multiple posts on template-parts with post formats
- How to display post_content from database in different on template page?
- Displaying POST content with HTML tags and all
- Create a hierarchical loop at predefined markup requirements
- offset and max_num_pages in pagination gallery
- Even with PHP plugin get_posts not working in widget area
- Sort posts by title, sort array by largest number [duplicate]
- Transient Loop Not working as expected
- show/hide attachments
- Find owner of coupon
- Link on post title only if post have content
- Category Attachment Pagination 404 Error on 2nd Page
- Display message once per session to users with a specific role
- How to display multiple Post meta_key/meta_values by SQL query
- Shortcode created to check language not works
- Listing all sub-pages?
- How can I export post data in xml format?
- allow user to select pages from dropdown in my plugin
- How to set a custom path, for ajax image upload folder in admin?
- Recent post display using shortcode
- How is WordPress manipulating the posts like there are folders?
- Can I use `.phtml` instead of `.php`
- conditional statement for custom taxonomy
- how to save selection meta data in user profile on frontend
- Can’t extend some core classes
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- Accessing the database from a plugin outside of action hooks
- Adding subdomain to home_url for “add_menu_page”
- How to make a search button that will search my website?
- Iterate through posts based on array of categories
- Custom query, checking values of multiple meta keys
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- wp attempt focus, disabling without touching core
- Genesis framework comments broken?
- Shortcode to show the code
- db converts decimal number wrong
- Issue with php version 7.2 in running search
- Can I make get_users() query global?
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- preg_replace regex problem
- iframe not showing in content on blog page
- Get the name of menu item with wp_nav_menu
- What’s wrong with this piece of code? [closed]
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- Twentyfifteen style author comment
- I installed WordPress locally now how do I login?
- Attaching images to posts manually (i.e. with custom code, without the use of an API)
- How do I add my PHP app to a WordPress page whilst keeping semantic URLs?
- How do I choose not to display the title header on a specific page?
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Cascading dropdown select search based on Parent Page & Child Page
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- I can’t go to the page archive-{post_type}.php
- Loading Widgets Via Child Theme
- (solved) WordPress Site not loading properly
- Class ‘WP_Privacy_Requests_Table’ not found
- Use Search Term in html link and redirect
- register_block_type is not working properly
- WordPress creating a compund query or using data from one post type to access another
- AJAX numerical pagination problem in TwentyFifteen-child theme
- Store data from JavaScript object to custom table in user account
- Permalink doesn’t navigate to post (changes only url)
- Javascript Tab Gallery with Advanced Custom Fields
- Generate a radius search of custom post type locations
- If input field has value Require another field – PHP
- Popular Post Not Show
- how to set category name for a post
- Move wordpress sidebar on homepage up to new position
- How to get shared CSS body class between translated WPML pages [closed]
- Can’t get options with $data[‘variable’]
- Custom archives page by month and year – nesting problem
- kali php problem [closed]
- Why is my array_diff usage breaking things?
- Bulk data save in custom table