Store the value is a function or make it global;
function get_variable_1(){
return 5;
}
OR
global $variable_1;
$variable_1 = 5;
But.. really, what you need to do it to read a bit more about the basic of PHP to understand how variables and functions work – global variables are not really a good idea and neither are functions which single return values with accepting arguments.. so you need to plan your PHP application to use both concepts correctly.
Related Posts:
- How to get the active theme’s slug?
- Which hook callback has priority if both plugin and theme use the same hook?
- Uncaught Error: Call to undefined function get_user_by() after moving function from theme to plugin
- add_meta_box (Will display only in specific page admin WordPress)
- All sites themes functions.php have been changed
- Why namespaces are rarely used in WordPress plugins?
- WP Plugins – Use includes to display page content
- My single.php page does not show the related data to the post which is clicked
- how can I do something on new user registration?
- How to make a dynamic css class whose name changes every visit to confuse scraper
- I receive taxonomy id
- How to include files relative to a file’s directory
- speed up pagination for huge database
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- Trying to include files in plugin isn’t working
- Plugin Admin panel checkbox unchecked after submit
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- Custom Plugin scripts from admin working in frontend
- WordPress Cache delete on plugin uninstall
- Replace old theme that understand old css (vcex_icon_box css_animation)
- Remove a div class with condition
- Hooking into the HTML header container
- How to get a post views count using ‘WordPress popular posts’ plugin
- How can I make the search bar in my wordpress site search all of the pages rather than just the blog posts?
- I want add repository theme folder
- Things that saved lose when logout
- Woocommerce: deleted single-product.php, everything still works. How is it possible?
- What is the process for reimplementing a back up WordPress?
- Template from scratch: Sidebars not showing widget
- Including a PHP file via a function that is part of a plugin?
- Display static pages instead of category, in code
- White Screen When Includding A Folder With PHP Files
- wordpress illegal string offset ‘parameter’ error
- Two sites one PC
- Real estate schema markup not showing up on Rich Results test
- Custom page template from plugin does not work with pre-installed themes in WordPress 6.6.1
- Tips for using WordPress as a CMS? [closed]
- is_plugin_active() returning false on active plugin
- Unable to check if plugin is active
- Preserve custom URL parameter on more pages
- if plugin is active? check if plugin is enabled or not?
- Making plugin unique to not conflict with plugins with the same name
- How to store ACF custom fields data in a custom table
- Trying to disable plugins doens’t work
- shortcode doesn’t work
- dequeue not work
- Have Plugin Handle Specific URLs
- Translating plugin inside the theme [closed]
- More than one text-domain is being used because of the included templates for plugins
- Different UI in WordPress
- How to add equivalent of php include to one page (as plugin?)
- Hooking in to replace the Sidebar/Widget areas
- Image upload and download from front-end
- Child Pages Short Code plug-in and hover capabilities?
- Using Wishlist Member and I need to access a user’s status
- How can I list all installed plugins/themes/versions from CLI/API?
- Use wordpress plugin in codeigniter
- Notice: Uninitialized string offset: 0 in social sharing mu-plugin
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- Only allowing some emails to create an account [closed]
- How to protect WordPress from security scanner [closed]
- how can I query all wordpress users of a blog
- Get ‘Headers already sent’ error for the plugin I am creating when I try to login
- How to redirect to same page after form submission
- Built a second plugin but it overwrote the first one
- WordPress: Add custom add_filter for custom functions
- I want to use wordpress themes and plugin to develop website
- preg_replace() No ending delimiter ‘.’ found [closed]
- Categories from front-end, checkbox selection doesn’t work
- Per theme plugins?
- How to fix these PHP Warnings with the “Feed JSON” plug-in?
- How can I adjust my function so the page editor still loads in the backend?
- Calling PHP function with AJAX
- WordPress fresh installation did not update default plugin and themes to latest version
- Looping the data from WordPress database using foreach
- Rename a folder via HTML POST request
- Defining constant in a plugin to use in another plugin
- Failed to load resource: the server responded with a status of 500 () post.php
- WordPress panel is not loading after plugin activated with error: HTTP ERROR 500
- Custom SportsPress list
- Adding link for logged in user? [closed]
- wp_login_form() ignoring login_form action hook
- Images is not showing after migration
- Create csv file in plugin
- Child Theme Changes Are Not Reflecting In Parent Theme
- Changes required to make new plugin from existing
- Input gets deleted/overwritten after changing to different Admin Menu
- Plugin Breaking WordPress Login
- How can I allow for the password protect feature to allow visitors to enter any number at all?
- Allow users to download media files directly from Amazon S3 (AWS plugin)
- Like/Dislike plugin crawler problem
- php include returns 1 as output with other outputs [closed]
- Adding a script & php to functions.php
- Divi Template A Few Questions
- Trying to use wp_register_script/style and enqueu them from an array – getting an error [duplicate]
- qTranslate‑X is not translating all shortcodes
- How do I call an action hook into wp_ajax hook callback function
- Remove H1 title in admin post edit screen
- How prevent STDOUT of Plugin_Upgrader->upgrade(…)?
- WordPress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted