I would stay stick to the function. PHP caches functions for speed and efficiency. In some situations, using a function is faster then using a variable.
There are other benefits too – imagine if you changed the name of your variable – you would have to go and update every piece of code where it’s used.
Related Posts:
- Create a variable with string, array or multiple values
- Best way to access variables in template markup
- What’s the difference between home.php and index.php?
- Custom single template for a specific category
- How to insert a logo in the header?
- What is $post_id? is it a global variable in WordPress?
- How to move page template files like page-{slug}.php to a sub-directory?
- What WP folder can I use to write files to?
- How to move page templates to custom folder?
- get_stylesheet_directory() returns wrong URI… localhost/using vhosts
- Page template in two level deep folder
- Is it possible to manipulate the list of page templates?
- Different wordpress 404 template for different post type [duplicate]
- How does WordPress decide what template to use as frontpage
- How can I get wp_head() as a string instead of echoing it?
- Why does my short code get executed before other content?
- How can I see what template parts are being called for rendering the viewable page?
- Add a preview to a WordPress Control Panel
- Add a #hash to the links in my custom menu
- Problems with Layout inherit in theme.json
- How to Handle CSS for Multiple Header header.php Files?
- How to load different CSS in different Header?
- Static Front Page problem
- Returning Variables back into a template
- Can not Remove Archives and Meta from Sidebar
- How to override BuddyPress 3.0 bp-nouveau theme files?
- Move my theme style.css into a folder
- Passing variables to template parts
- How should I store global information such as a phone number so that it is editable through the CMS?
- When developing a distributable Theme, does it HAVE to be “inheritable”?
- Setting hero/splash section as a blog post
- Can wordpress run in root of existing php site with no theme on index.php but all other WP posts/pages?
- Where is the correct place(s) in twentysixteen’s header.php to add a Google webfont?
- Add a theme via symlink
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- Any tag pagination page (except the 1st page) loads index.php template instead of tag.php
- How do I update WooCommerce template files in my theme? [closed]
- Loading files for theme and child theme (Require)
- New template, where to place CSS?
- Check if password protected post is visible
- get_query_var() and permalinks
- after_setup_theme, Global Variable and Theme Customizer
- What is the best way to handle multiple calls to get_template_directory_uri() and similar functions?
- Toggle Sidebar Display
- Add theme templates for child categories into the template hierarchy
- Move theme templates to subfolder without losing page associations
- Where can I access my custom page template?
- Theme development question regarding layouts
- Why are theme templates organized as multiple point of entry PHP files instead of reusing your theme’s index.php?
- WordPress page templates in a directory
- WordPress Theme Development: How to redirect templates the right way?
- Disable front-page.php template
- How do I create a custom partial / template?
- Change the template of multiple multisite pages at the same time
- Load child template based on parent
- create-guten-block in wordpress theme?
- Override template file i subfolders
- Single Page theme [closed]
- Single page site with history.js
- Do i need to keep all the default WP templates files in a theme?
- How can I detect hierarchal relationships beyond children (grandchild, great-grandchild, etc)?
- how to display search term in the template full site editor
- Sort wp_query by sum of two meta fields
- How to override p2 breathe theme plugin in content template file?
- Move default page templates to sub directory
- What can I use for small text when converting to WordPress?
- Is it possible to make *.js and folders visible in theme-editor
- Where to place template files?
- Is there any tool to find lines of codes responsible to generate front-end HTML elements?
- How do I get the trackback count of a post in wordpress without writing an SQL query?
- Load sidebar template just once to prevent multiple animations
- Replace single_template filter with what for default posts?
- How to implement pagination in category.php template
- Local variable name in setup_postdata()
- Template for front page (latest posts)
- Using wp_add_inline_style Inside a Template File
- which template should I use for single category post?
- Should I use template files or just use conditional tags in index.php?
- Different templates for each category level
- Child theme in separate WordPress Install
- How to show children pages as array
- Display content on Single page
- Using require_once for parent-directory not working but is working in sub-directories
- How can I fix the even/odd child classes comments so that the comments are unaffected by the top-level even/odd?
- Current URL path variable
- How Does One Create a Global Variable Repository
- Problem with multiple menus in theme
- Enable WP to accept standard jQuery code embeding between the tags [duplicate]
- Make theme editor to show all theme’s files
- What is the advantage of using home.php over index.php for the front page
- Extracting Distance from FacetWP Proximity Function to Display in WordPress Template
- Best practice to create required pages
- How customizable is a self-hosted WordPress blog compared to a Blogger blog?
- What is the point of using the front-page.php template? [closed]
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- What is the point of using archive.php instead of index.php?
- Theme template file for a specific custom taxonomy
- How can one use variables in a template or template part without polluting the global scope?
- How to create a template for a post in Query Loop block?
- Twenty Twenty-Four Theme, where to put the personalized CSS style rules?