You could return the data and set a local variable:
function get_album_info() {
$album = array(
'art' => wp_get_attachment_image_src( get_sub_field('album_art'), 'full' ),
'date' => get_field('album_date')
);
return $album;
}
$album = get_album_info();
echo $album['art'];
echo $album['date'];
Related Posts:
- How to access custom class methods from any include without using global
- Setting a cookie in functions.php and it gets deleted when working on an other function
- Best way of passing PHP variable between partials?
- Custom page with variables in url. Nice url with add_rewrite_rule
- Passing variables to templates (alternatives to globalizing variables)
- 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?
- Global functions on WPMU
- Defining a global array in functions.php?
- Assigning WP functions which echo to PHP variables
- Passing values from a widget to a function within a plugin
- Using $themename Variables
- Create a new query in function.php to filter blog posts
- How to pass variables from a function in functions.php to an other one
- Define PHP variable from a seperate API if statement
- Passing global variable from header.php to functions.php
- problem loading stylesheets to wp_head dynamically
- How to Use Global Variables Inside Header and Footer
- Undefined variable error in new function
- Getting the teaser text without overriding global variables
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- add_menu_page() with variable function
- Do I Need to Prefix Variables Inside Functions?
- Updating custom query var with multiple values
- Change Page Title
- Custom global variable not working in function
- get variables data from functions.php to template wordpress (without global variables)
- External api call and make global variable for any page visitor enters , page-home, page, single etc
- Getting value of variable from functions.php and debugging it
- Pass post ID from archive template to functions file
- Using a variable in name of dynamically-called helper function
- Add array of category IDs to global variable?
- getExcerpt: Make ellipsis appear only if character limit is reached
- Settings in functions.php used by a plugin
- Using Output from one Function and calling it into another
- Trying to get this function to show below the content
- add variable to actions/functions across different files (woocommerce)
- Function the_content
- Problem in outputting shortcode
- Edit TinyMCE Button Functionality
- need help with ‘… read more’ excerpt in functions.php
- Problem in shortcode outputting content
- Editing Global Variables from Inside Functions
- Load a Child Theme’s style.css just before the closing tag
- Load CSS conditional on custom field is present
- Can’t wrap my head around this function – any help would be appreciated
- Modify sub_menu function to show pages below a specifically set page
- Figure inlined width trigger distorted layout
- Changing the color of post title [closed]
- Add custom class to all URLs on entire site
- wp_nav_walker that interacts with widgets to setup mega menu
- How To Get WordPress Categories Last Update Date?
- save_post hook – headers already sent?
- Expanding a function to call a plugin or show a link
- How to programmatically GET (to know) which Sidebar (or) which Menu is being used on Different Pages?
- How to add a meta information to the URL?
- Is it possible to change parameters of Parent theme function in the Child theme?
- Why are some custom javascript files working but some are not
- Getting error while trying to use custom comment function
- Error function main() is a non-object to construct my Ajax.php
- Load WP Admin scripts in a child theme functions file
- List Most Read Posts from last 7 days (with custom post type and other meta queries)
- Adding stick post button to edit post page
- add_role menu pages are not visible
- Preventing PHP Execution in Parent Theme
- Excerpt length: get 2 paragraphs
- Sanitize html, where to sanitize
- Remove heading tags on line break
- WordPress Javascript Widget jQuery Dependency Issue
- wp_upload_bits – define (sub)folder / (sub)directory before filename?
- Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?
- Apply height and width for the_content() inside youtube video tag
- How to mirror exactly the left admin menu on front end?
- Adding a filter with custom function to the menu / navigation
- Check if excerpt is empty at loop-portfolio
- Mail function not working with user accounts
- Open image size links in a page instead of direct image link
- Function to get the name in database table from the comma separated string
- Function not recognizing page id?
- Add Function For Instances of Custom Text in Multiple Category IDs to display in post content
- Move captions under gallery images in twenty fourteen theme
- Increase Comment Author Gravatar Size On WordPress Default Comment Function
- Random text changing to weird icons in both admin & front end
- Register a widget area when a theme option has been saved?
- Blank child theme – functions.php problem
- Force changing the Site Title and add link
- Allow the access over wp-login.php
- Meta Box value not been pulled in
- Create input select image URL?
- Show the post date using the wp_get_archives() function?
- How to add a piece of code in function
- Why does my visual post editor break when I try to add a TinyMCE button?
- Remove Captions from Custom Gallery function.php
- Automatically delete posts based on query
- update_usermeta don’t work
- jQuery HoverIntent is not a function
- Show the online status of the current post’s author
- Functions.php in child theme that loads CSS file breaks website
- Update functions.php from WordPress dashboard
- Create html from function