Title: $term_id Error
Last modified: June 12, 2023

---

# $term_id Error

 *  [owlbooks](https://wordpress.org/support/users/owlbooksdk/)
 * (@owlbooksdk)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/)
 * Stock locations works perfect, but I am running into issues with it conflicting
   with other aspects of my website. Our programmer looked into it and said that
   it’s erroring out on line 261 of your stock-locations-for-woocommerce/stock-locations-
   for-woocommerce.php file.
   “The $term_id returns a NULL value”
 * Are you able this?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fterm_id-error%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Fahad Mahmood](https://wordpress.org/support/users/fahadmahmood/)
 * (@fahadmahmood)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16813483)
 * I am surprised that your programmer is telling you the wrong line number, maybe
   you are modifying the files on your end. Correct line number is 266 and it is
   not producing any error, I would request you to come up with a solution instead
   of reporting these things, troubleshooting takes time my friend.
   Anyways, please
   replace that line with the following one and let me know about the outcomes. 
   And please ask your programmer to understand this line, we are storing the value,
   which can be zero, not null, into the $term_id variable. We need it further, 
   there is no return thing is being used.**$term_id = (int)(is_archive()?get_queried_object_id():
   0);**
 *  Thread Starter [owlbooks](https://wordpress.org/support/users/owlbooksdk/)
 * (@owlbooksdk)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16814304)
 * Definitely not modifying it on our end. Changed the code with what you posted
   and it didn’t fix the issue. If I deactivate your plugin then no error… you can
   see it without error in our dev environment with your plugin deactivated.
 * Error in Live: [https://www.owlbooks.dk/best-sellers/?term_taxonomy_id=34](https://www.owlbooks.dk/best-sellers/?term_taxonomy_id=34)
   
   Dev: [https://staging-1685720091.owlbooks.dk/best-sellers/?term_taxonomy_id=36](https://staging-1685720091.owlbooks.dk/best-sellers/?term_taxonomy_id=36)
 * Anyway, thought you would be able to see the issue without too much trouble. 
   But if not, then just close the ticket out as unresolved. That’s Cool. No big
   deal my friend.
 *  Plugin Author [Fahad Mahmood](https://wordpress.org/support/users/fahadmahmood/)
 * (@fahadmahmood)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16814342)
 * You are pointing out the wrong line number, please check the following file and
   tell me the correct line. I am not getting this error.
   [https://plugins.trac.wordpress.org/browser/stock-locations-for-woocommerce/trunk/stock-locations-for-woocommerce.php](https://plugins.trac.wordpress.org/browser/stock-locations-for-woocommerce/trunk/stock-locations-for-woocommerce.php)
 *  Thread Starter [owlbooks](https://wordpress.org/support/users/owlbooksdk/)
 * (@owlbooksdk)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16814392)
 * I replaced the code here:
   [http://staging-1685720091.owlbooks.dk/wp-content/uploads/image.jpg](http://staging-1685720091.owlbooks.dk/wp-content/uploads/image.jpg)
 *  Plugin Author [Fahad Mahmood](https://wordpress.org/support/users/fahadmahmood/)
 * (@fahadmahmood)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16814429)
 * Doens’t matter where you replaced it, actually your dev site is telling me the
   line number 289 where actually the error is
 * [https://www.owlbooks.dk/best-sellers/?term_taxonomy_id=34](https://www.owlbooks.dk/best-sellers/?term_taxonomy_id=34)
 * So what is the line number 289 in your dev site, ask your developer to give me
   a screenshot of that file, I want to know about the line number 289.
   Also please
   use the help tab on the settings page, there is an option of urgent help to look
   into these kind of matters. If you notice, line 289 here is different from yours
   [https://plugins.trac.wordpress.org/browser/stock-locations-for-woocommerce/trunk/stock-locations-for-woocommerce.php](https://plugins.trac.wordpress.org/browser/stock-locations-for-woocommerce/trunk/stock-locations-for-woocommerce.php)
 *  Thread Starter [owlbooks](https://wordpress.org/support/users/owlbooksdk/)
 * (@owlbooksdk)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16814487)
 * Looks the same:
   [http://staging-1685720091.owlbooks.dk/wp-content/uploads/image-1.jpg](http://staging-1685720091.owlbooks.dk/wp-content/uploads/image-1.jpg)
 *  Plugin Author [Fahad Mahmood](https://wordpress.org/support/users/fahadmahmood/)
 * (@fahadmahmood)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16814578)
 * I am surprised that the same code is giving me the term_id as 0 without any problem.
   
   Try the following:
 * $term_id = (int)(is_archive()?get_queried_object_id():0);
   $term_id = is_numeric(
   $term_id)?$term_id:0;And ask your developer to use [https://developer.wordpress.org/reference/functions/is_wp_error/](https://developer.wordpress.org/reference/functions/is_wp_error/)
   to handle this and let me know which solutions works so I can add that improvement
   in the next version, this is the blind way to handle the issue, kindly use the
   urgent help option instead. I doubt there is some other problem on your page.
 *  Thread Starter [owlbooks](https://wordpress.org/support/users/owlbooksdk/)
 * (@owlbooksdk)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16835786)
 * STILL UNRESOLVED.
   That didn’t help either. Still throws up all kinds of errors
   and conflicting with other plugins. We’ve decided to drop your plugin because
   it’s causing way too many issues.
 *  Plugin Author [Fahad Mahmood](https://wordpress.org/support/users/fahadmahmood/)
 * (@fahadmahmood)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16836321)
 * I certainly offered you the support beyond the common practices but you even 
   reply with your convenience and like to report the issues only. Nobody else reported
   the same issues which means, your WordPress environment has something to be reviewed,
   conflicts are never related to one plugin scripts, there are other aspects need
   to be considered.
 * The nature of the issue reported wasn’t resolvable as you were expecting, I tried
   to respond quickly, provided you the possible fixes but actually you were never
   interested in troubleshooting. This plugin is an open source solution, everyone
   can contribute in it, reporting issues aren’t the only option. If your developer
   couldn’t find the reason behind this issue, I was here to troubleshoot but you
   chose the strict pattern of just reporting.
 * Thank you

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘$term_id Error’ is closed to new replies.

 * ![](https://ps.w.org/stock-locations-for-woocommerce/assets/icon.svg?rev=2471943)
 * [Stock Locations for WooCommerce](https://wordpress.org/plugins/stock-locations-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/stock-locations-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/stock-locations-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/stock-locations-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/stock-locations-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/stock-locations-for-woocommerce/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Fahad Mahmood](https://wordpress.org/support/users/fahadmahmood/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/term_id-error/#post-16836321)
 * Status: not resolved