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
- I have issue to retrive post thumbnail with rest api
- Custom page template from plugin does not work with pre-installed themes in WordPress 6.6.1
- wordpress theme backend admin only
- Missing argument 3 for wp_register_sidebar_widget()
- Make id column as AUTO INCREMENT on plugin activation
- How to Include a Loop Template File in a Plugin
- Write to / remove from default .htaccess file from plugin?
- Deactivate Plugin on Theme Switch
- Update Option Error: Notice: Undefined index
- How can I display a contact form for out of stock products in WooCommerce?
- ‘Customize’ button in admin bar for CSS
- Pass a php string to a javascript variable
- get shortcode value
- How to get number of Affected rows from wordpress dbDelta() function
- Unable to install theme recommended plugins on Multisite
- Theme or Plugin: Where should I write my code?
- Show price with Geo IP location
- WordPress Ajax Callback
- Add category to body class
- The called constructor method for WP_Widget in GFWidget is deprecated since version 4.3.0! Use
- Plugin Development sqlite or WordPress’ database
- More than one text-domain is being used because of the included templates for plugins
- How to review WordPress website php version compatibility?
- Plugin Deactivate Self on Activation Errors
- printf – problem to understand code
- Custom Post Type Plugin not loading category template and loading 404 instead
- How to Know if a Plugin can be used with my Theme [closed]
- Sending email from inside a plugin using PHP PEAR
- Auto delete WordPress users according to time
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- How to trigger $_GET request within admin plugin page?
- Wp favorite posts get user favorites in profile using buddypress [closed]
- Storing Options in a Shortcode
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- How to generate video out of images via WordPress plugin
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- How can I get WordPress to save comments in markdown format?
- add_query_arg not working
- problems with wordpress and php version 5.3.3-1
- WooCommerce get_price returning wrong price when used via ajax
- How to ‘clone’ a wp plugin to make small changes
- Not able to open category post [closed]
- Open Post Thumbnail in New Child Theme File in WordPress
- add mediaelement.js plugins into WordPress video player control bar
- Shortcode button dosent work for all posts. Work for first post only
- Where should I save an API key of my user when installing my plugin?
- Prevent a plugin from being automatically activated
- Reusable functions and tools (Framework)
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Accessing post’s meta data based on user’s click of a post
- How To Clean The Malware Infected & Hacked WordPress Websites? [duplicate]
- Do I still need a theme to use page builders?
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- How to prevent users to download videos from lms website?
- Preferred way of cacheing a value in php
- Redirecting to home page after login as custom role WordPress
- WordPress Redirect Not Working – AJAX Callback Response Not Picked Up
- How to Use Parameters with a Do_Action Function Within PHP Tags
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- How to remove html code in excel downloads using phpspreadsheet with wordpress plugins shortcode
- Add Product Subtitle to Woocommerce Product Page
- Self deactivate plugins after an action occurs