get_most_recent_post_of_user() is for multisite installs to get the most recent post of the user from each blog.
Here is a comparable function you can use that will return the post object of the defined users most recent post.
function wpse_get_user_recent( $user ) {
global $wpdb;
$recent = $wpdb->get_row( $wpdb->prepare("SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type="post" AND post_status="publish" ORDER BY post_date_gmt DESC LIMIT 1", (int)$user ), ARRAY_A);
if( ! isset( $recent['ID'] ) )
return new WP_Error( 'No post found for selected user' );
return get_post( $recent['ID'], 'ARRAY_A' );
}
Usage:
$post = wpse_get_user_recent( 36 );
setup_post_data( $post );
the_title();
the_content();
wp_reset_postdata();
Related Posts:
- Why use if function_exists?
- get php variable from functions php and echo it in theme template files [closed]
- Use AJAX in shortcode
- Include files in child theme functions file
- Remove Container Element From wp_nav_menu() Markup
- WordPress function like is_category for subcategory? is_subcategory?
- WordPress Theme Update Action?
- How to get woocommerce inventory status [closed]
- Using a private method as an action callback from within a class
- Auto close (hide) custom metabox / set default state
- Does WordPress Development Mode Exist (with not minified JS)?
- WP_Query in functions.php
- Implementing DNS Prefetching with WordPress
- wp_delete_user with username
- what is the meaning of settings_fields()
- Organize functions.php
- Remove Page Title from Static Frontpage
- How to override WordPress registration and insert an auto-generated username?
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- change a post status when users update posts?
- How often is functions.php loaded?
- update_post_meta for custom field not working upon form submission
- Display height and width properties with the_post_thumbnail() or related function
- Cleaner way to access custom fields in code?
- Add a new subscriber role using a function
- Why functions.php file is called 8 time for just one page load?
- Display a text message if the shortcode is found?
- How to store / access files in child theme folder
- How to set the jpg image compression for specific thumbnail sizes?
- Function to auto-set a featured image that is already in use
- Delete pages and Create default pages for all new network sites
- Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
- Post thumbnail relative link and HTML modify
- How would go about if I just want a temporary function?
- How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?
- Generating rel=prev and rel=next only on wordpress categories
- Custom HTML in specific category single page and its descendant categories
- Modify a function without editing template
- How to hide unused profile fields?
- Override widget in function WordPress
- WooCommerce – Want to show multiple currency for a single product [closed]
- How to change or add user role after getting post request data about pay? [closed]
- How add various functions within 1 conditional?
- Add to cart php not working [closed]
- Create cron job for update translations automatically
- WordPress converts media extention URL automatically to video player
- Automatically include all php files in a child theme directory
- Custom taxonomy widget in admin area
- Add a unique class to HTML tag/element
- Removing specific menu items?
- Which function required?
- AJAX error handling for submit function in functions file
- Do I need to use wp_reset_postdata for my function?
- get_pages() Returns Only One Item
- Use a shortcode to display custom meta box contents
- how to make has_block() see inside blocks too
- Solved: redirect to another page using functions.php
- Getting the teaser text without overriding global variables
- add_theme_support( ‘title_tag’ ) is not showing title on index.php
- Solution dealing with Child Theme / Parent theme functions
- Function to pull data from user meta not working
- referencing the current user in a page i created in wordpress
- Counting posts and trigger it [closed]
- When are the user meta fields created in the database? Admin vs Woo API REST
- is_product_category(‘Services’) not working
- How to automatically add counted number to navigation menu items?
- Replace theme function
- How to access custom class methods from any include without using global
- Is it possible to use ‘wp_insert_post’ function within a for loop?
- save_post function keeps triggering: Warning: array_map(): Argument #2 should be an array… when restoring from trash
- More than one search results page template for two searches on site
- How do i create a search option for pdf’s only
- What is best practices to move the following code into a function?
- Correct way of Enqueue self hosted fonts in sass project
- function syntax is off,
- Restrict certain roles registrations by domain
- Replacing term/taxonomy archive pages with search queries
- Return ACF Field value function
- Best way to add image to recent posts widget?
- Issues with add_query_arg() not passing a variable
- wp_enqueue_script only works outside of action
- How can I include user meta information in the resulting array of a WP_User_Query?
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Force changing the Site Title and add link
- create submenu page – error function not found or invalid function name
- Get Value of Custom Field
- How does child theme functions.php work with parent theme functions.php? Is it like CSS? [duplicate]
- Undefined offset: 2
- Need a functions that adds (adm)/(mod) if current user is admin/moderator right after their username
- Sorting date results from a query
- Using is_plugin_active within functions.php
- Add title & subtitle to shortcodes
- Button generate a random URL [closed]
- How to Delete Posts by title?
- How do I add functionality to images?
- Display function from functions.php in tag.php
- AJAX values converted to PHP Variables?
- Custom Post Type Search
- Comment turned Invisible
- How to add more than one menu for logged in members?