Wrong hook, because what gets passed to wp is the
Current WordPress environment instance
not
The WP_Query instance
like it is e.g. passed to loop_start.
You could actually just do your check inside the function callback you hook to loop_start.
Edit/note:
You could just have done global $wp_query; inside the wp hook, it is actually the first one where access to $wp_query is possible, to have access to it – not that I recommend doing it though. A better place – or at least the one I probably would go for – to hook into is the pre_get_posts action, which does get passed $query – the WP_Query object – by reference.
Related Posts:
- Manually set global $post vars with an ID, in order to use template tags
- How to prevent a post from being deleted?
- Limit access to posts/pages by user roles
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- How to work with Syntax Highlighter Evolved?
- User-Specific Timezones? Hack? Plugin?
- jQuery plugin only in one page/post
- How To Ignore a Filter On Applying Filter the Content In a Function
- Share buttons on article footer
- How to create a Page alias in WordPress
- How to extract images of post and pages excluding header and logo image in wordpress?
- Dynamic HTML not displaying at respective place
- Fastest way to loop through all posts?
- How to filter content post only on save
- Tag link suggestion plugin
- Collaborative post submission [closed]
- Is there plugin to show recent posts from one website in the widget area of another?
- How use %like% in sql statement wordpress
- How to get 1 or 2 specific posts on top of my wordpress blog?
- With W3 Total Cache when I publish a post it does not appear in the homepage. Only if i purge all cache [closed]
- The problem with WordPress Importer
- Hiding posts – WP Hide Post not working
- submit posts by unregistered users in wordpress
- Any built-in function to associate a post to category through a plugin?
- Display post lists in 2nd paragraph
- Matching Chapters to a Custom posts [closed]
- WordPress display breadcrumbs using Yoast plugin [closed]
- Preg Match All doesn’t Allow echo first character for WordPress Taxonomy Tags
- Two problems on my WordPress installation [closed]
- Excerpts on category page
- How to pull email and name from Flamingo plugin
- Which widget to use for display category post with view more? [closed]
- External RSS feed to WordPress Portfolio
- Unable to add TAB character to post?
- how to add text to posts from tags
- Would Gutenberg be considered a PlugIn?
- pagination on data fetched using SQL query
- How to get the first post and second post in a wordpress blog?
- ‘Organize Series Plugin’ as muti author feature
- Is there a way to make the main page only display a brief description of the full article?
- WordPress plugin Post Creation [closed]
- posts from multiple post types in one slider
- How to display the featured post on the category page?
- Flickering sidebar when scrolling page [closed]
- how to execute some code after a post is published in WordPress [duplicate]
- Post status doesn’t update to ‘future’ every time?
- trigger email when post is published by someone a user follows
- Grab ID from post from plugin and use it to create an object
- I would like to remove date display on photo preview
- Change website directory safely to add a static page on startup
- Show related posts based of current ACF field name in a single page post (a loop within loop)
- Embed PDF into wordpress
- Hook Scripts and Styles in WordPress
- WordPress plugin: Getting posts where checkbox selected
- WordPress “Add new tag” button is not working
- How to auto strip hyperlinks & images in wordpress post
- how can authors to define custom pages?
- WP Editor, save content and category on frontend
- Plugin for TinyMCE to create reference to other posts
- Add posts from other WordPress blog to the current one
- Link Posts to External URL
- How do I allow users to supply a photo/image to be used instead of the grey/white silhouette?
- help intercepting save_post through plugin
- Update existing post dates to random dates and time
- How to display the custom post related blog by category?
- WP Forms not displaying,becomming an fatal error
- .com creates automated link in post
- Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
- Pagination (including title of each page) in a post for a long posts
- How to echo a PHP Code After the Content
- WordPress Product Detail and catalog
- WordPress CPT Url metabox collection
- Identify if the_post hook is being called from the admin post list
- Include post_date in search
- Add Filter to get_next_posts_link
- How to Save settings of custom tab product page in admin side in a database?
- Displaying friend’s posts only
- Trending Tags based on post views
- Hidden Some Setting on Post or Page [duplicate]
- Better code/text editing for posts and pages?
- WordPress list child pages of custom post type
- Style WordPress Custom Post Type Single Page
- SWF in wordpress post
- Posts are deleted everyday at night
- Retrieve post thumbnails
- Enforce conditions only for draft posts using WyPiekacz, ignore pending and published posts
- Using Postmash plugin in WordPress 3.3.1
- What is the correct method for updating post content from a plugin?
- Get post id in Post Page within Wp-admin
- PHP $_session is not work in wordpress
- Embedding BitBucket Code in Posting
- Next and Previous Pagination button not displaying in WordPress
- Notifications on WordPress Website [closed]
- Sell “create a post”, paid account for post creation
- Looking for membership style plugin with edit option [closed]
- Change from blogger to wordpress
- Is there a plugin or another way that can help me find out the underlying files of a page/post? [closed]
- Randomly display activity posts on home page with buddypress
- How to check if the post exists in any of the categories?