Data associated to a user can be saved in user meta. Save the recipe post IDs in an array for the user.
$my_favs = array( 42, 23, 99 );
update_user_meta( get_current_user_id(), 'user_favs', $my_favs );
Then to query all recipe posts with those IDs, pass the array as the post__in
argument to WP_Query
:
$my_favs = get_user_meta( get_current_user_id(), 'user_favs', true );
$args = array(
'post_type' => 'recipe',
'post__in' => $my_favs,
);
$recipes = new WP_Query( $args );
Related Posts:
- WordPress Paginate $wpdb->get_results
- Custom Search Query
- Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123
- Retrieve and display data from custom db table in admin area?
- How to find if a post with custom_field == X exists?
- Custom search page and search by title, content and tag
- Modifying loop on a custom page, strange behaviour
- How I display post of the post type group by year of post?
- Load more posts with multiple queries
- Hi, I wanted to make custom search with multiple fields
- $wpdb->replace: WHERE?
- wp_query get post custom taxonomy in search.php
- Order posts with a custom field but also without
- Save title as custom field on custom post type
- Add content in between of foreach
- Custom Loop Query For Search Page
- Custom SELECT Query With Multiple Meta Values (Ordering Problem)
- Display posts by combining multiple meta key
- Custom select query two tables by a meta key
- Custom Same Page Search
- Fatal error Call to a member function insert() on a non-object [closed]
- custom user meta query
- Recent activity query WordPress
- How to query term_id of a Custom Taxonomy by name
- WP Search Form Query: Add Author’s posts into search query
- query variables for custom taxonomies
- display text generated via custom get query string
- Custom query pagination with php parameter as arg problem
- How to automatically pull an information from a form field onto an other page?
- Query Posts to display all posts with category “custom field value”
- Query 1 custom post type, each day, alphabetically
- Multiple Taxonomies Using Custom SQL Query
- Search a meta field for a value in all posts
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Custom MySQL query to list post
- Custom Query Arguments
- Custom Query for Taxonomy
- Include plugin´s table in custom query
- User Query Multiple Orderby Clause
- Best Practices for Regression Testing WordPress Websites?
- Custom Walker: how to get ID in function start_lvl
- How to include own css on wordpress tinymce editor?
- wp_trim_words() does not trim the_content() in WordPress
- How can I create an alternative home page?
- Gallery Shortcode: using link attribute to link to a specific image size
- Limit comments displayed on basis of user_id
- Customizer image control default value showing in customizer but not on frontend
- Change default status and replace the icon for an hamburger menu
- How to Register and Display Widget for Custom taxonomy
- How to access my php page in wordpress
- How to display post title & excerpt when mouse hovers on an image?
- Search result page redirect ex.com/?s=searchterms to ex.com/searchterms
- Add styles with wp_add_inline_style only if modifications exist wp_add_inline_style
- Add custom field to woocommerce variations [closed]
- How would you implement a CTA infront of a videoplayer? [closed]
- need help with a user-specific custom page template
- Alphabetical Custom Menu
- Can’t receive $args[ ] to my custom widget
- Can I create my own custom Attachment Display Setting?
- What WordPress Hook Is Used Before Signup Data is Saved?
- One WordPress install for main site at domain.com and blog at blog.domain.com?
- How to locate where an element is generated?
- Combine two conditions in one statement syntax [closed]
- Is there a way to add a new value into a stored custom field value?
- spaces in a text
- How can I add interactive python console to my website? [closed]
- Show “Read more” link only when inserted manually
- Customizing Users in Admin Area
- How to Escape Custom Meta Data And Prefix Custom Meta ID
- Remove Customizer Control Choices (Type: Radio Array) using Child Themes
- Grabbing a data from wp_usermeta
- wordpress shortcode not working
- how to replace old DW site with new WP site? [closed]
- How To Style Links in Content Area With Tag Automatically?
- Meta Tags by Meta Box
- What is the best way to setup WordPress for version control and PhpStorm while allowing updates
- Get whole linked with wp_list_pages
- Force WordPress to load a specific template
- Troubles about insering a POST with a SQL query, post_status
- How to activate flash cards
- Transferring theme and imported post attachments
- Personalized Gallery what are my options?
- Trying to use .htaccess to redirect /profile to /login-2?action=profile
- Embed Latest Track (Dynamic Updating) SoundCloud
- Gender based user avatar
- Javascript Tooltip not fully working on my wordpress page
- Add a menu item to admin dashboard which isn’t a link? [duplicate]
- How to narrow the area between buttons on Helium theme sidebar? [closed]
- bulk generate wp taxonomy tags from wp title with self php script
- Build custom pdf from users choices
- Show Header When Not In Iframe
- Background setting isn’t applied to entire sidebar height
- Changing a setting in the wp-admin/customize.php reverts CSS styles to parent theme [closed]
- Function to query by custom field and category
- Confused about customising widgets
- Changes in comments.php in the child theme does not show up on the site
- how to modify request to get_template_part()?
- Loop display only 5 posts
- How to display product variations on same row
- Create a page for each database table entries