Don’t put your variables in single quotes.
This:
if(isset($submit)){
$args = array(
'numberposts' => 10,
'meta_key' => '$filter',
'orderby' => 'meta_value',
'order' => 'DESC',
'post_type' => 'things',
'post_status' => 'publish' );
$mystuff = get_posts( $args );
$name = $filter ;
}
Should be this:
if(isset($submit)){
$args = array(
'numberposts' => 10,
'meta_key' => $filter,
'orderby' => 'meta_value',
'order' => 'DESC',
'post_type' => 'things',
'post_status' => 'publish' );
$mystuff = get_posts( $args );
$name = $filter ;
}
Related Posts:
- Custom column on CPT not showing correct value when meta data not set
- Get posts by meta value
- post formats – how to switch meta boxes when changing format?
- Execute action after post is saved with all related post_meta records (data)
- advanced custom fields update_field for field type: Taxonomy
- update_post_meta not saving when value is zero
- Restrict post edit/delete based on user ID and custom field
- get_post_meta returning empty string when data shows in the database
- publish_post action hook doesn’t give post_meta_data
- Remove post meta keys
- How to get all term meta for a taxonomy – getting term_meta for taxonomy
- delete unused postmeta
- Should I sanitize custom post meta if it is going to be escaped later?
- Query between two meta values?
- Using Advanced Custom Field (ACF) to insert meta description on each page
- How to add meta tag to wordpress posts filter?
- Correct processing of `$_POST`, following WordPress Coding Standards
- Metabox Data not being saved [closed]
- Options to get my custom post type metadata via the WordPress API
- Generate an Email address from that of the Post Author
- How to get the total number of meta_values based on a custom post type?
- Does “update_post_meta” check if value is the same before updating?
- Add a meta value if admin , editor or any other user have open a post in edit mode
- How to show Published date and/or Modified date
- Validate form in functions.php, send errors back to template
- wp_update_user isn’t instantly?
- Finding the page id
- WP_POSTMETA – What do these values mean inside the data structure?
- Update Line Item Meta Data – WooCommerce API
- How to use update_post_meta inside wp_trash_post
- Display All Custom Post Fields and Values, Unless Empty
- Unset field from an array not working as expected
- Update post_meta with WooCommere variation data
- What type of index should I use for postmeta?
- Post MetaTable Overload
- Meta function issue
- Custom RSS Feeds & Post Meta Data
- Get a row from a separate table by matching a posts meta_key to a tables ID column
- get_post_meta is showing file url in url bar
- Display get_post_meta if contains value
- Should I save this mulit dementional arary as one post meta?
- How to check if a post meta key/value pair already exists for a specific post
- Reset/delete post views meta/custom field after X hours or minutes or seconds
- Have lots of meta for posts, is it better to get at all at once or each individually
- IF Custom field value equals ZERO
- Query posts WITHOUT a custom meta field
- Add box with custom per-page properties
- get_post_meta not working when variable used for post ID
- Update post meta dynamically
- Duplicate rows in meta table, any known relations in WC?
- Adding Custom MetaData
- Suggestion to make posts have multiple associated items
- How to add post meta in while loop?
- Is it safe to add a new field to meta_value field?
- Send value of PHP variable in template via hidden field in a form
- Need a SQL query to update meta_key=’_price’ with value in meta_key=’_regular_price’
- Display current user’s custom post meta in sidebar
- Why is my get_post_meta not properly calling the custom field when attempting to embed a YouTube video?
- add_post_meta doesn’t work
- How to get single value from get_post_meta() array of values?
- How to echo value of a meta select box to the browser
- wordpress update multiple posts post meta
- get_template_part() isn’t loading author information
- get Insert id for meta field
- How do I add a fixed value to get_post_meta();?
- Is there a way combine posts meta_name?
- Add post’s category as a meta tag to the post
- Format meta_value [closed]
- How can I query for posts using a date stored in post-meta?
- Form Post / Session Variables not Working in Query with Pagination
- Count Post and Page Views based on meta_value Using Shortcode in Dashboard Widget
- How can i set media attachments to the author of the post or page for already existed posts with attachments
- Removing Malware
- How to get posts by meta value as multi-dimensional array?
- After updating the custom post type, metafields disappear from the post.php edit menu, how do I fix it?
- Add post meta data date to event
- URL from get_post_meta() is broken my URL
- Something adding an excessive meta description
- get_post_meta and add_post_meta not working
- Export media library with metadata and import into new blog
- how to query posts using value in meta post array
- Multiple meta key and value search in the query
- Re-pointing images to cloud storage
- undesrtanding get_post_meta function
- How to call get_post()?
- add_post_meta only adding 1 character
- Retrieve posts from meta key
- Assign postmeta in bulk
- Re-order posts inside tax query
- How do I delete element from a serialized array upon deletion of a post?
- Using mysql queries to delete custom post types based on meta_value
- Get meta information from post parent
- Write query according to post_meta
- Why values dont shows in custom post column?
- get_post_meta of multiple posts?
- Counting number of identical meta keys
- Use a Variable in update_post_meta as the $meta_key
- I am stuck between post meta function to call unique id
- Chance post id into post name
- get_post_meta() returns nothing in save_post, publish_post, wp_after_insert_post