Okay, I’ve solved this. I just needed to replace $query->query_vars['page_id']
with get_queried_object_id()
and everything works!
However, I just read Pieter’s response and it appears that indeed, according to the codex, it’s not supposed to work. Weird though, because it IS working. I guess we’ll see if anything breaks…
Related Posts:
- Change of query var in pre_get_posts not maintained
- pre_get_post alter current post id
- Setting post_id for single.php based on URL without a redirect
- How to check during “pre_get_posts” if WP performing default query for specific custom template?
- Is there any plugin development framework
- How do I add CSS options to my plugin without using inline styles?
- Plugin – create a page without it appearing in the side menu
- Is wp-content/install.php a Drop-in?
- Handling results from data hooked into admin_post
- How do I create links at the top of WP_List_table?
- How to write testable classes in WordPress
- get_template_part from plugin
- Edit or Remove Plugin .htaccess Using The Admin Panel
- WordPress scheduled task is called but not executed
- How to create collections that are edited in admin?
- Get list of available wordpress actions
- How can i list current author’s categories?
- How can I call “preview post” from wp_remote_get with authentication?
- When is it too late to call the action wp_enqueue_scripts?
- Use js script from one plugin in another plugin
- Rest Api How to get results of child categories with one api call
- Build dynamic page from cURL (HTML page) response with plugin
- How to store accumulate multiple option values in a single array using Options_API
- Add Post and Comments menu no longer visible
- template_redirect for single posts w/ custom fields
- can I prevent WP users (even admin) from deleting custom categories?
- Proper way to hook wp_get_attachment_url
- How to install WordPress Popular Posts plugin twice?
- Get the link text
- Is Dreamweaver CS5 a serious choice for theme/plugin development?
- How to deal with equal & similar arguments for a function?
- What parameter should I pass to wp_enqueue_style to depend on the themes stylesheet?
- How do I obtain a list of categories assigned to the current post?
- Modify hard-coded conditionals for roles to custom roles
- need to get user ID after a user logs in
- Callback is not called in add_settings_field() when passed as part of an array, but recognises that it’s there. It’s passed Class to Class using OOP
- Plugin translations not installed but… strings are translated!
- Secure Pages Best Practice
- Does wp_login only trigger before an user signs in into the admin panel?
- How to access noticeOperations from withNotices
- parse content from wikipedia article replacing search term with the title of article
- Putting a resized image into media library with wp_get_image_editor(
- Using ReactJS in the WordPress admin for plugin development
- How to use github to update my plugin
- Thickbox doesn’t respect dimensions when used in admin [duplicate]
- wp_nonce_field displaying twice
- jQuery in WordPress Plugin
- Why is my plugin version 0.1?
- WP Plugin Running before jQuery
- Settings API – format container of setting and setting’s description
- Delete option of a Plugin
- How to include jQuery into my plugin so I can use it on plugin page?
- Prevent WordPress automatically processing certain URL queries
- Apply function to update_option Variable
- Proper way to include stylesheet for panels
- WordPress multisite,use same cookies across all website?
- How to check via conditional tags for a single plugin page?
- How to make and save custom form in custom plugin page?
- How to save post meta as an array in Gutenberg?
- WordPress Gutenberg InnerBlocks renderAppender not showing with template
- Duplicate shipping method logic to another shipping method [closed]
- REST Endpoint API 404
- How to disable a jQuery plugin on WordPress plugin page
- Add a custom menu item that supports wildcards
- jQuery UI tab does not work in the plugin page
- Using HTML links within translatable string
- Adding an external stylesheet to a plugin
- WP_NAV_MENU filter targets all menus
- How to share user data across multiple WordPress websites?
- Load stylesheet in edit category page?
- How to properly create table in plugin
- Restore svn trunk of my plugin repository to the initial state?
- How to use attributes in competent of Gutenberg
- How to add .ini file type to the plugin editor to read and edit?
- How to write a custom shortcode name book?
- Hook to execute after deleting a Custom Taxonomy
- get the term_id of current taxonomy page
- WordPress Ajax not returning Response
- WordPress Iframe for blog image
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version
- Add the Twitter Bootstrap framework for the development of my plugins
- Remove from a div by class name from post page if post author role is not administrator
- Convert each new line in the textfield as a new value in an array
- Enqueue script not working
- auto create only 1 wp page in activate custom plugin
- Calling dynamic_sidebar in plugin gives error
- How to add chunk of php, html, and sql code to variable an append to $content
- edit-tags.php in plugin admin menu hides when is the active page
- How to create a custom search form and handler?
- Best way to handle a form post in plugin
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- Method to retrieve category names and IDs only as an array?
- How To Remove The Filter That Adds JetPack Related Content To Dom [closed]
- Fixing plugin for wpdb::prepare
- Remove text from confirmation message
- Can I use an array to create multiple tables?
- Using “add_image_size” to register custom image sizes inside plugins not working
- How do I access the contents of WordPress Classic editor in admin area with JavaScript?
- How to boost WP custom post REST API GET queries by custom taxonomies
- I want to redirect user to an amazon product page from my wordpress website when they add product to there cart [closed]