Using a Query Loop Block with Variables (Custom Meta)
-
Query Loop Block is extraordinarily powerful. I am using FSE. I want to filter data via any number of meta keys and values from the editor. I think it might be good if the editor could allow a method to include such variable data , which would support the desired behavior. Please let me know what I am missing if this is already possible.
Use case: I want to combine that power to filter posts using a dynamic variable (populated from PHP) with a custom meta value. For example; Filter all custom post types if the meta value on the WP User object matches with a meta value one or more posts. I want to do this in a secure way so that folks cannot change the author-id in the browser editor to see other folks posts.
It is not clear how one could use stored meta values in the FSE (code view) or in visual block mode. The idea is that sometimes one needs to access stored meta for a user and provide that as a filter on a query block. There seems no way to connect a variable found in dynamic data (PHP) in a specific block enabled page. However the query block appears to support various hardcoded attributes in the FSE.
Since the page has blocks everywhere I don’t expect that I could drop into PHP to grab my user meta value?
Alternatives might be if I could set the query in code and then it would filter as needed using some dynamic data (PHP?). Not sure of WPQuery behavior. Could I load a query before the page is presented and have the posts use the active query?
- You must be logged in to reply to this topic.