You could, but you wouldn’t be able to debug anything that happens before the theme is loaded. This includes most of WordPress loading and all plugins loading. You need to put it in ‘wp-config.php` so that it’s set before anything happens. Also, global debugging is not something themes should control. It’s not appropriate, even if it worked.
Related Posts:
- Prevent notice and warnings in error_reporting?
- How to debug WordPress correctly?
- How to fix Uninitialized string offset: error on a checkbox in WP Settings API
- WordPress debug messages not displaying
- Getting a WordPress Debug Strategy
- I have this error notice ‘wp_enqueue_script was called incorrectly’ in my plugin
- How to receive notification of deprecated API elements and functions?
- How do I specify where to save the debug.log?
- Post meta vs separate database tables
- How to add a javascript snippet to the footer that requires jQuery
- Enhance Media Manager for Gallery
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- How to create an API for my plugin?
- Plugins in symlinked directories?
- Update Option Stored in Multi-Dimensional Array
- How to use PanelColorSettings in custom Gutenberg block?
- Is there a way for a plug-in to get it’s own version number?
- How to add tab which is visible only in admin side of product in woocommerce? [closed]
- Best practices for using the transients API
- $wpdb->insert_id
- Remove profile picture option (and other things) from profile.php (in admin)
- Replace audio/video enclosure with player?
- Contact Form 7: wp_mail doesn’t work after update to 4.6
- How do I print a notice only on certain admin pages?
- Hook the Keydown Event in the TinyMCE Post Editor
- Elementor Fatal error: Class ‘Elementor\Widget_Base’ not found
- How Can I Add a Filter to Class Instance Only?
- Gutenberg ServerSideRender is deprecated, how to work with new wp.serverSideRender component?
- Headers already sent error with CSV export plugin
- How to add HTML / Form to an Admin Bar Menu
- Add an image gallery to a custom post type?
- Unit testing wordpress plugins with plugin options
- Create a clickable name in WP_List_Table for Plugin Admin
- Plugin development without Theme adjustments?
- How to Make a Category Always Selected?
- Unable to write test cases for a WordPress plugin using PHPUnit and WP-CLI
- Call activation hook multiple times
- Adding custom code into header.php using a plugin
- Two-step login process – Is it possible?
- WordPress Localization and Templating
- WordPress Settings API: saving multiple rows of similar data
- Modify how gallery.js builds the shortcode [gallery ...] in tinyMCE?
- How to use is_multisite() in a must-use-plugin?
- Why after a file is programmatically deleted, is there still a reference in the media library?
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- why creating tables using $wpdb is not being executed while installing plugins?
- How to update the language used by wordpress from a plugin
- Is there any background process that I can run from plugin without depending on page hits on a website without affecting page-load speed?
- Woocommerce how to update variable product price programitically?
- DataBase connection problem with PHPUnit and WordPress
- Using $wpdb object in a widget
- Unified Approach for Placing Option Pages
- Define a function outside a class and call the function using action or filter hook
- Modifying WordPress plugins
- On plugin deactivation hide its shortcode
- Modify a Free Plugin available on wordpress.org & include with my Premium Theme? [closed]
- Using wp_filesystem in Plugins to store customizer settings
- Can I use the different settings sections over different pages using the save options group?
- WordPress removing data attributes for scheduled post
- WYSIWYG editor in WP 3.2 plugin
- Ethics question: what qualifies as a fork? [closed]
- Verify Nonce returns false – Request Nonce returns correct value
- How to i18n text coming from the db or from an external source
- Plugin settings not saving
- How do I write a shortcode that opens and closes?
- What is minimum time interval for which a cron be scheduled?
- Registering and using actions which return results in a Plugin class
- Plugin developement and SVN
- Can I change header.php of current theme through a plugin function?
- How to replicate Media Library “Add New” on Plugin Settings Page
- WooCommerce Conditional Tag inside plugin
- Plugin writing: access file that was just uploaded
- Gutenberg blocks not getting styled on back end
- Writing a plugin which needs to upload files
- Calling is_single() outside the loop
- update woocommere total value on checkout based on selected payment method
- Add code inside specific wordpress standard function
- Conditional hook based on the core function that is calling it
- Using WPDB to output raw XML fails because of wp-blog-header.php
- Add a Save Button to Custom Meta Box [duplicate]
- Best way to save custom css for an block
- How to hook a custom user function to a wordpress core ajax action?
- How to change the hover content of a specific menu item on WordPress?
- PHP – Extend WordPress Woocommerce Revenue Analytics with custom field
- Amending REST API function without deactivate/activate plugin every time changes is made
- How can I listen to events in Gutenberg block?
- It’s possible to passing a ref to FormTokenField from parent component using forwardRef?
- How to show filters on table when using WP_List_Table
- Sending post request with wp_remote_post not working correctly
- Plugin callback page
- Is nonce in PHP form and Ajax both necessary?
- How to add WordPress Admin “Insert Link” UI (searches through existing posts for URL) and functionality into a custom plugin?
- Unable to change footer using wp_footer action hook
- Add a default WP comment form to forum template
- Gutenberg: import dependency or assign from global variable?
- Input value from metabox is not found in $_POST after post save
- CMB2 Form Throws No Input File Specified in custom WordPress Plugin
- Following WordPress Markup Is mandatory, got awkward resultyby wordpress standard markup?
- Input in plugin widget does not allow spaces
- Steps to Update a WordPress Plugin That We Developed