I would flag post as member_post
when it is submitted to database and use this flag to sort them.
function wpse_287048_flag_member_post( $post_id ) {
if ( wc_memberships_get_user_active_memberships() !== false ) { // Check if user is member
update_post_meta( $post_id, 'member_post', 1 );
} else {
update_post_meta( $post_id, 'member_post', 0 );
}
}
add_action( 'save_post', 'wpse_287048_flag_member_post' );
Then you are free to retrive your post sorted by member_post
.
function wpse_287048_get_posts() {
$query = new WP_Query(array(
'post_type' => 'post',
'meta_key' => 'member_post',
'orderby' => 'meta_value_num post_date',
));
return $query->get_posts();
}
Keep in my mind that all posts which you want to retrive must have member_post
meta_key with some value otherwise they would not be selected from database.
Related Posts:
- Display all posts in a custom post type, grouped by a custom taxonomy
- How do you get the count of posts in an archive page?
- How to use a custom post type as front page?
- Display several random posts, but make sure a condition is met
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Retrieving 3 latest post from each of 5 different custom post types
- How to solve suspected memory issue in custom WordPress loop?
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- How to create posts (not post template) to be displayed on projects page?
- WP_Query post at custom position
- Query for posts from any post type but only add instock products
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- WooCommerce – Show orders for a specific product ? [closed]
- exclude custom post type by meta key in wp_query
- Query for posts in 2 taxonomies
- Query Custom Post by Category
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Impossible to get Attachments Outside WordPress?
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Woocommerce query specific product from specific category
- Unable to get post content from custom post type loop
- Lists Posts from CPT that match the Title of the Page
- Help Structuring Query for Archive Pages
- Loop on front-page.php
- wp_query to find posts by year and month
- Remove duplicated values from a loop
- Custom Post Type Loop within Shortcode
- display posts of custom post type with custom taxonomy
- Get all post from a post type
- Trying to add a class to post links
- postsperpage value not being applied
- Display the current post in browser as the first post in a loop (for a slideshow)
- Display post from custom post type
- List all Custom Post Type posts excluding certain Taxnomy term
- foreach loop inside the loop creating duplicates in output
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- How do I list a custom field and custom taxonomies for each result in a loop?
- Custom Post Type Query W/Category Dropdown
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Custom post type pagination error
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- What is the most efficient way to execute recursive complex queries?
- Page that lists publications by classifying them by taxonomy
- posts_per_page in custom WP_Query does not override “Reading” settings?
- Exclude a specific post in a Custom Post Type
- Pin posts to top of custom loop
- Filtering posts based on three taxonomies
- Pagination Not Working When Used With WP_Query() `offset` Property
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- SEARCH QUERIES – REVERSE OUTPUT
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Error in the page of a CPT file in WordPress
- post_type incorrect for custom post type
- Staggering featured post using ‘sticky’
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- subtracting the current post form then whole loop, which is generating all CPT titles
- Mix Facebook and Twitter feed into custom posts
- sorting in wp query based on custom field value
- Custom post Query and WordPress Post Query Clash
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- Only show current category post
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Error in WP Query. If variable is empty it is displaying previous post value
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- How To Loop Through list with Custom Post Types
- CPT or Custom Table for Repository of Serial Numbers
- Is it possible to add query parameters on the archive page?
- Custom Post Type + Category archive
- Loop with Custom Post Type and Taxonomies
- display news with pictures 3 small and one large (loop)
- Post data in separate divs with incrementing class using WP_Query
- How can I pull information from my loop and divide them seperately?
- Fallback if statement based on the number filtered from it
- next_posts_link returns same content of 1st page
- Custom loop won’t work, can’t find problem
- Custom post-type’s pagination not working in category.php
- Query Custom Post Type by Tag
- Fourth page of custom post type archive page does not exist
- Catergory args causing loop not to show
- How do I correctly query posts from a post ID?
- display custom post type from register taxonomy
- How to exclude certain portfolios from a loop
- Custom post type and have_posts() return empty result
- Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]
- How can I show posts with the same tag?
- How to insert a post from a different post type after every nth post
- Complex Custom Loop with Includes
- Query Multiple Post Types and Paginate Newly Created List
- SOLVED: Shortcode to display Divi project filtered by tag in WP Query loop
- Pre defined checkbox / radio button state based on value stored in ACF fields in checkout form WooCommerce
- author archives, showing all custom post types, problem on pagination