Functions – yes.
Class methods – no (but prefix the class name).
Variables – inside your functions/methods – no (like in your example); inside template files – yes, because there are lots of global variables exposed by WP in them, and you might get conflicts…
Related Posts:
- Best way of passing PHP variable between partials?
- Custom page with variables in url. Nice url with add_rewrite_rule
- How Can I Access a PHP Variable in Another PHP Function
- Is it better to assign functions like get_the_id() to a variable if it’s used multiple times?
- Assigning WP functions which echo to PHP variables
- Passing values from a widget to a function within a plugin
- Using $themename Variables
- How to pass variables from a function in functions.php to an other one
- Define PHP variable from a seperate API if statement
- problem loading stylesheets to wp_head dynamically
- Undefined variable error in new function
- add_menu_page() with variable function
- Updating custom query var with multiple values
- Change Page Title
- get variables data from functions.php to template wordpress (without global variables)
- Getting value of variable from functions.php and debugging it
- Pass post ID from archive template to functions file
- How to access custom class methods from any include without using global
- Using a variable in name of dynamically-called helper function
- Add array of category IDs to global variable?
- Setting a cookie in functions.php and it gets deleted when working on an other function
- getExcerpt: Make ellipsis appear only if character limit is reached
- Using Output from one Function and calling it into another
- How do I access variables outside a function [closed]
- Trying to get this function to show below the content
- add variable to actions/functions across different files (woocommerce)
- What’s the difference between WordPress random_int() and PHP built-in function random_int()?
- Issue with wp_get_attachment_image() and SVG file type
- deregister scripts on certain page
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Formatting post content to exclude gallery
- Why do I get undefined function export_wp()?
- How to remove the embed_footer?
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- Hide some items from Screen options in dashboard for products
- Function to show only first instance of shortcode
- Using the child theme functions.php to change the customizer.php on parent theme
- Can’t Update function.php after writing short code
- How to get last updated row or ID in wordpress
- Load parent theme files before child theme functions.php
- 2 Loops, Only Displaying 1 Loop in Both Loops
- edit role display name and label name without plugins
- Two functions.php files in one theme
- wp_dropdown_categories and custom attribute
- Converting html to wordpress images not showing
- How can I add text to all posts/pages/categories/homepage etc
- Make parent page only link to first subpage
- Pulling Twitter RSS feed not working as expected (fatal error)
- Related post using post title
- Move Post to different category if post_meta field is 0 or is 2 days old?
- Find a Javascript ID when trying to deregister?
- Functions For Calling Specific Elements
- Set Taxonomy based on post status
- Is There Any Built In WP Functionality For Combining Form Fields To Return Specific Data
- How would I go about replacing this function in my child theme located in inc/template-tags.php
- Condition OR for current user ID
- Retrieve a value from Yoast SEO to use to set a default twitter card image honoring overrides
- wp_create_category deprecated?
- If user is logged-in display/hide something
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- WordPress Excerpt – How to remove the first link using functions.php
- Sortable column (by numbers) in admin users
- How can I add a class to a nav li depending on URL?
- Access category within rss2_head hook?
- Is there a built-in function to duplicate existing posts?
- load CSS only for administrators on backend
- Modifying the_posts_pagination from within functions.php instead of template files
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- Prevent WordPress Automatic Logout
- Insert Address fields into function
- functions php file [closed]
- How to remove admin footer text from inside child theme?
- Problem with images URL after filter applying
- How add body_class from wp_termmeta
- Rewrite Question Mark in Post Template with URL Parameter for clean URLs
- Modify function to only return values for the user that’s logged in
- WordPress performance – send all metaboxes to function or to call it again
- Custom attributes to javascript tags
- How to add php within jquery
- Is it possible to put a function somewhere other than the functions.php file?
- wp_enqueue_script() not working
- How do I change where “You must be logged in to comment” directs users?
- Login cookies blocked after customizing hashing method
- Class parameter in get_avatar args doesn’t get added to output
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
- locking content with overlay/pop up ads
- How to use `foreach()` in ajax call
- How to list out all values from the get_body_class array
- Mail function not working with user accounts
- Function not recognizing page id?
- Register a widget area when a theme option has been saved?
- Blank child theme – functions.php problem
- Conditionally write open graph meta property in header
- Pull random comment from specific post, display on homepage with shortcode
- Using array page name together with page id to deregister script
- Give a function a unique ID
- Hiding Google Analytics code based on theme options
- how to handle multiple forloop?
- How do i set global variable in a function in wordpress functions.php
- How to add more than one menu for logged in members?