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
- How can I get page slug
- Add custom classes to anchor in wp_nav_menu
- Upgrade from 5.0.4 to 5.1.1 causes $theme to be null
- How to alter the text of the post “Excerpt” box label in WordPress post editor?
- How can you develop on a live WordPress installation that is using W3 Total Cache? [closed]
- How to Auto Approve Comments on a Specific Page?
- How can I display recent posts from a particular category in my header?
- WordPress Errors in generated by theme check plugin [closed]
- List authors with posts in a category
- More than one meta field in a single meta box?
- how can I remove the sidebar from my wp homepage [closed]
- How to develop child theme for thesis
- API response to be stored locally
- Why is the post type on the search result page random?
- How can I use wp_query to show all product data using just the products ID?
- Using a `Template Parts` folder instead of an `Includes` folder in a Custom WordPress Theme
- approach to pass additional parameter in post URL
- WordPress Media Uploader in page template (On Front-end)
- auto-populating custom nav with all items from custom post type
- Replace function in a child theme
- How to register and enqueue JavaScript files without breaking plugin dependencies?
- Adding the_content() return warning count()
- change default RSS feed URL
- WordPress custom post type image in RSS
- Ajax call returns 0 when add_action is inside a class in functions.php
- Search page results conflicting logic – Search result caching?
- header, stylesheet not being read
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- Custom Post Types set up, how do I style the main slug page?
- How to register dynamic settings in WordPress Customizer?
- How to add audio files to audio player in WordPress custom theme?
- Query custom post type that has a serialized relational advanced custom field value
- Data Validation & Sanitization for Big HTML Blocks
- Rotating Header Images
- How can I display a specific number of post in a category via a url
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- Not able to call class in NHP framework
- WPMU – How to echo only one URL
- load src of images that attachs in wordpress’s post
- Add Field To All Pages