Try changing the get_queried_object()->ID to get_queried_object_id().
All the get queried object may not have a property name $ID. So this get_queried_object_id gives the $queried_object_id property value, which gets set on instantiation of WP_Query class. If the $queried_object_id isn’t set then it’ll give you 0.
Related Posts:
- When unit testing a plugin, does the plugin need to be in the wp-content/plugins directory of the WordPress tests install?
- How can I prevent a plugin from updating unless it’s minimum PHP version is met?
- Stackoverflow type of badge plugin giving warnings in WordPress 3.5
- Twillio How To Send SMS for Custom Post Type
- Determining where fopen() is writing files when used from WordPress AJAX call [closed]
- How Restrict access to admin dashboard by specific static ip?
- Overide a function that is inside a plugin
- How to get images from EDD post?
- Add multiple attributes to product from php
- How to install and activate a plugin via an external PHP script
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Add a plugin before main container
- Shortcode to generate and save password in a file
- I don’t understand how this parameter works..?
- problems with wordpress and php version 5.3.3-1
- WordPress Redirect Not Working – AJAX Callback Response Not Picked Up
- WordPress takes too much time (100 seconds) to load – Front end and back end
- how to change the verification url of pie register plugin of wordpress?
- wordpress plugin is not activating from widget
- Using meta_query to get date type values from post_meta table WordPress
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- wp_get_post_terms is difference obj model than the one in rest api response
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- WpDataTables – View Image Directory
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- Server configuration for WordPress – Do I need install PHP-SSH extensions for WordPress on Fedora28?
- Using plugin functions/methods within templates
- WordPress shows error related to allow_url_fopen
- Delete mobile menu button [closed]
- How to replace WordPress Media Upload Window with user’s device window?
- Using color picker in plugin, does input attribute order matter?
- Redirect to another page using contact form 7? [closed]
- Activate my plugins via FTP
- Is wp-app.php or wp-apps.php needed for WordPress?
- How to add apply_filter for a class property in plugin
- Warning: Use of undefined constant list_all – assumed ‘list_all’ (this will throw an Error in a future version of PHP)
- How to distinguish if a plugin is not installed or just not active
- JavaScript in a PHP plugin
- Checking the count within a foreach loop
- Is there a function to list all uploaded images? How can I add one?
- A server-side hook failed when committing plugin code to SVN
- Content-Security-Policy Headers are there and showing the correct settings, but still getting a refused connection
- Need to replace Currency Shortforms
- Api external with wordpress
- How to delete all categories programatically?
- How to use custom Javascript code inside a plugin?
- How to use printf to output two links?
- speed up pagination for huge database
- File Uploader – Upload without adding to Media Library
- Building a plugin into a theme
- 2 wordpress site same database
- How to redirect to a page after the form is submitted
- Trying to include files in plugin isn’t working
- WP Insert Post If user refreshes override new post
- How to makes changes on the shop/category/tag pages but not on the product pages in woocommerce?
- implement custom roles in custom plugin
- How to get current cart values using WC_Shortcodes?
- How to authorize viewing and clicking a function only logged users?
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- Cant create table on plugin activation
- How to arrange custom posts in the backend/admin by custom taxonomy
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- How to ignore fields if empty?
- Why is my shortcode not working?
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- the content of the uploads folder gets deleted periodically, how to figure out what causes it?
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- implement checkbox or toggle switch in plugin code
- Custom Field used to allow a Free Story; no longer works
- How to send new visitor to a splash page for only one time in wordpress?
- Cron job shedules replace?
- Create a form and have custom menu display based on user answers?
- redirect to a custom page
- Can i add custom code in Source in specific page, Header from function.php?
- Problem with conditional woocommerce custom checkout field
- GET web api method from a WordPress PHP script
- How to change text in a page by utilizing a custom user id?
- Adding link on title its in description but not in title see screenshots attached
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Editing Global Variables from Inside Functions
- How to save information related to post in database?
- Save selectlist value (taxonomy) in wp:wp_set_object_terms
- Page doesn’t load
- Posting code inside the post instead of in the template file using shortcode
- Metabox Data not saving
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- Xml output not places where i want
- Including a PHP file via a function that is part of a plugin?
- How to fix ‘Call to undefined function do_settings()’ error?
- How to tweak a plugin without preventing it from updating
- Place max_execution_time in plugin [closed]
- Integrate Razorpay quick payments plugin with contact form7 plugin
- Passing an input variable through a switch statement
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Posts in Admin only display 1 Post instead of all Post in admin area
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- WordPress Convert queries to slashes using function.php
- WordPress Throwing Deprecated Errors on its own Files
- plugin doesn’t retrieve data from database
- PHP Deprecated function Optional parameter $function