The global $wp_query
object is not what you are looking for by the time you get to single.php. Instead use global $wp
object. Try changing your code to this:
global $wp;
if (array_key_exists('myvar', $wp->query_vars) && isset($wp->query_vars['myvar'])){
echo 'custom variable recognized';
}
print_r($wp->query_vars);
Related Posts:
- Redirect to another page using contact form 7? [closed]
- How to disable 3.1 “Admin Bar” via script for the admin user?
- First wordpress blog, should I make my own theme for maximum customizability?
- query posts in wordpress
- Is using eval() ok in this scenario
- posts_nav_link(); not showing up on static pages
- Get list of months with posts
- How to list all images in uploads directory except those that are attached to any post
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- Remove query string specific key value
- Metadata Query when storing data as array possible?
- Apply different Class for each element in a foreach()
- Keep sticky posts out of query unless they have featured image
- defining a folder location in order to recall it
- Dynamic content based on a URL parameter
- Storing the contents from txt file into The_Contents”
- WordPress shows error related to allow_url_fopen
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Displaying icon image for WordPress post formats, is there a cleaner way to do this?
- Why am I getting a white screen without a slash at the end of the address?
- How to query the latest 5 posts and sort them by title?
- Is there any tool to find lines of codes responsible to generate front-end HTML elements?
- 2 loops, is_home won’t work, count is off
- ACF Pro make URL Linked in Custom Template [closed]
- Issue On Displaying Pages with Post Name Permalink
- How can I prevent posts with no title showing up in my query?
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- CSS class on last post in loop ( custom query )
- Custom Post Type Query issue
- How to order by multiple date meta_values?
- How to create query to get top 3 sticky/latest posts
- Getting posts to exclude from array
- Get all posts as an array ID => Name
- Custom post type permalinks do not appear using the link functions
- Changing sidebar.php and footer.php depending on URL
- Changing footer depending on URL (poli language site)
- WP_Query not getting all posts, just tagged posts
- tag__in does not return posts
- Toolbar Hidden in a Virtual Page
- View list of all attachments on site
- multiple queries to get posts from same category?
- Search.php gets metadata from first post
- Modifying WP URL handing code?
- Link to RSS feed not clickable?
- Best practice for implementing a blog page / section in wp_menu_nav()
- How to use multiple check-box values to work in a function and insert values in database
- get main URL from subdirectory with php
- how to display recent post by category on home page
- Trying to get pagination working on WP_Query() post grid
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- Correct (and secure) way to escape url when using href attribute
- Loop carousel slider in wordpress
- Not the typical order by posts by date question
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- issue displaying variations in custom template using WPeC 3.8.9.2
- Show post thumbnail only if it exists using timthumb
- Im using a right approach to use this class inside WordPress theme?
- Upgrade to WP 3.2/ and Server to php5 breaks theme? [closed]
- How to manage wordpress knowledge base/wiki/posts collections
- Variable ++ in query loop
- Exclude first post from wp query
- How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?
- how to retrieve the image title for image Post Format
- Different options per post type in WP_Query
- Data Validation in wordpress
- Iris color picker in custom theme option page not saving value
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- Live to Local on MAMP, not working, outputting functions.php code
- How to specify the path for require_once in a child theme?
- Adding the_content() return warning count()
- Is functions.php in themes applied to all templates?
- Warning: printf(): Too few arguments in helpers.php file
- Form search query – displaying ACF “Post Object” field as results
- WordPress Theme With Modified View
- Copying the theme style files and images to duplicate the website but with a difference
- How to include a mu-plugin as a theme dependency?
- Double Curly Brackets in Php
- What happens if a theme is no longer supported?
- where is real values of variables?
- Running a function on post update with new post meta
- Why still output /wp-content/themes/twentynineteen?
- Redeclare function after plugin activation
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- Check if( selected() )
- reduce duplicate code in wordpress
- Show message when query has no posts
- Convert a string into a decimal number for use in query
- HTML block gutenberg templates
- How to display SQL query that ran in WC_Order_Query?
- get_the_ID() doesnt work
- Use a filter on menu items that have children
- How to make function appear in sentence?
- WordPress does not load page template or anything else, just empty page with header and footer
- Widgets not showing on custom theme
- Do I need to create a child theme for JointsWP
- White screen when attaching css to function.php
- Assign custom classes to the divs inside the loop
- Array to string conversion on array_map
- Store metakey value as an array