The function below will show you how to get the page/post IDs or taxonomy term IDs for restricted content for chosen WooCommerce Memberships levels which have been assigned to a post or page.
Recently I needed to get each restricted category ID for the WooCommerce memberships plan associated with a particular page. Unfortunately that function doesn’t exists in the plugins helper functions. With a little digging we came up with a good solution that will return the object IDs for either a
'post_type' or a
'taxonomy' object which has been content restricted.
This is useful if you are trying to query those associated posts or categories from a particular post or page. You may even want to link an associated page or category. Using the IDs you can easily use a common WordPress function to do so. The page/posts or taxonomy term ID’s will be returned in an array.