You should probably provide different default if empty string is indistinguishable from your value.
$myvar = get_query_var( 'myvar1', false );
if ( false !== $myvar ) {
// stuff
}
Related Posts:
- When should you use WP_Query vs query_posts() vs get_posts()?
- order by numeric value for meta value
- How to query for most viewed posts and show top 5
- WP_Comment_Query pagination, delving into the unknown
- Sort posts by category name and title
- What is the most efficient way of querying posts based on visits and date for current day?
- Custom WP_Query order by post_meta and (author) user_meta
- WP_Query for WooCommerce Products
- Perform query with meta_value date
- Highlighting Sub topic in a post?
- Which custom query am I in and how can I access its properties & methods?
- how to retrieve specific product attribute value in an sql query?
- WordPress custom archive page
- How to speed up wp_query, took more 5s to run against 100k posts
- WP_query category__in not working, only pulls from first category
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Retrieve or Query Pages by ID
- How do you query wordpress posts using a math formula between multiple meta field values?
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- How to do a query on custom taxonomies that is uncategorised?
- Empty tax_query array returns an empty array
- Meta Query for specific months
- How do I search inside specific taxonomies in WordPress
- Different string for specifed post type on posts listing at homepage
- if/else on custom query gives 200 OK when condition not met?
- How to correctly pass values to wpdb->prepare()?
- Setting get_queried_object
- remove query arg from url after set query
- difference between like ‘%%%var%%’ and ‘%var%’
- Changing WP_Query params with url Query Var
- only delete post within query / for each statement (front end)
- query_vars filter not working even though query string parameter is present
- How to detect if query is runned from widget?
- Sort query by author: 1 author, then others
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- How to duplicate 5 posts out of WP_Query results?
- Order by summing multiple values
- WP_query sorting can’t sort danish letters (æ, ø, å)
- Slow queries on a huge database
- Multisite pagination issue by multi query archive 404
- Query with relation and one without relation using multiple taxonomies?
- How to get list of posts from permalinks?
- Is there a reason why Pages are not publicly_queryable?
- Check return value of get_posts
- Exclude some authors from query
- Query only the posts with a post format of “audio”
- pre_get_posts – Trying to get property of non-object warning
- WordPress query posts with multiple post_meta data
- Get a list of posts by specific category
- How to check the array values, what WP_Query has brought to me?
- How to add custom meta to ‘pre_get_terms’?
- Shortcode for custom query not returning results when attributes are added
- Should I reset $wp_query?
- Update query for wp_posts and wp_postmeta
- Get specific ACF key and value from all posts – no access to DB
- I am officially missing something about transient posts
- Insert images into wordpress post with a query
- WP_Query meta compare must include ALL array values
- Start Query from 2nd Post without offset
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- pre_user_query vs pre_get_posts
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- Meta query orderby meta_value_num sorting by role first
- How to query users by post count no less than 10
- Add to search posts query array with post IDS which will appear first
- WP_Query about meta_key and its array value
- Create global array to compare inside a query
- How to show terms from another taxonomy
- My entry results are not consistently alphabetized
- Own query vars are not displayed
- Ignoring ‘a’ when sorting posts
- Custom query for tag and custom tag from 2 post type
- wpdb get_results() returns only 2 rows
- Filter posts/pages by user_role array
- WP_Query secondary query failing
- Search Functionality broken by the wp 4.2 update
- Issue attempting a wp_query_posts with tags
- How to get several fields from wp_query?
- Passing query variables to a custom page template
- add_query_vars does not work
- Retrieve posts in custom post type and specific taxonomies
- Query Posts by date range with fixed beginning and end
- query by meta value then date and not empty meta value
- Custom post types loop on a page template
- Get the number of rows from $wpdb->get_results not working
- Parsing External Table Arguments
- Get Child Custom Post Content on Single.php?
- difference between methods of query
- Query posts by meta value and sort by another meta key
- How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page
- how to use transient method?
- query_vars category_name only display one catgory out of multiple categories
- Pre_get_post on CPT archive page
- Get posts that were most recently tagged
- A Depth Like Parameter For “get_posts”
- Search query alteration not working for meta values
- Send a variable with a URL and get a variable with Wp query
- Advanced Search – Is this possible?
- Use value from meta key array for use in WP_Query