WordPress caches the user information. There’s really no problem just to call get_userdata
every time you need it. The only thing you are doing by transfering it to a variable $userdata
is have WP fetch it from another place in the memory.
Note: read this post for a more general dealing with passing variables to partials.
Related Posts:
- Is including the loop necessary for page.php? [duplicate]
- How to get_template_part using AJAX?
- wp alchemy multiple image uploader output images to template
- How to show “teaser” posts on blog / archive pages, otherwise full posts
- How do i create a list-posts-page?
- is it bad to copy the loop for a template?
- get_template_part() to render single page Theme
- Jquery Slider for profile template
- Using the Loop to show all levels of subpages under a parent page? Halfway there
- Child Pages Loop
- Get post by page name or slug
- Loop that displays PARENT PAGE & CHILD PAGE & outputs GRANDCHILD PAGE title and content
- posts page – different lengths of excerpt
- Display subpages under parent page as a list within a loop
- What is best way passing variables to theme templates and using them different places like widgets?
- Identify the page being shown while in The Loop
- If Loop has odd number of posts on last page Custom style for last post in it
- Page template not displaying
- single page site with subpages
- How to loop through ALL pages?
- Does get_template_part pull data once in a loop?
- Custom search form to display users only
- Post Format single-loop.php using get_template_part
- Loop and Page template : my WP_query don’t take args
- Create a loop that gets pages with their template
- Loop after page content
- code suddenly appearing from my tempate second loop
- Problems with loop
- Get search.php results in header.php?
- WordPress Loop inside Loop?
- Template structure
- Order archive results by post id in custom taxonomy template
- Detect if current page is front page within custom query
- Default ‘post’ post type archive slug?
- Get Page content to displayin Bootstrap Modal
- How do I display an image before the first post of the loop when I’m using get_template_part?
- How to insert category list into post creation page, and retrieve chosen categories?
- Exclude page name from loop
- Stepping through a foreach loop – adding +1 to the end of it so next time it loops it starts on item 2
- Include multiple page ids in loop
- 404 Template customization | Want 10 recent Post on the 404.php error page apart from the error Notice
- Get post offset/posts page offset in single post page (outside the loop)
- how to replace get_template_part(‘loop’,’tag’) with explicit styled version?
- First archive page with a few posts
- Tags on page (not post) returns nothing – why? Improved clarified question!
- How to get user ID’s from multiple usernames?
- Second Loop Showing Only One Post on Single Post Page
- How do I put my frontpage featured image in a page template for home.php?
- get_template_part() Not Working in Loop
- Exclude page from loop results
- Get_template_part() problem with the_content()
- Problem with Front-Page.php loading recent posts
- How can have a conditional template tag based on the main loop within a secondary loop with new WP_Query(), using get_template_part()
- Get markup for post without loading into the template
- How to render the single post template with the post name?
- Print the whole page?
- excerpt not showing up
- WP_Query is only looping home page, not pages
- new custom theme – posts displaying on top of one another
- Override orderby to create list of users by custom meta_value
- How to sort a loop after most viewed
- WordPress: query pages except remove one page
- On click some element i want to use some template
- How to loop specific Category menu from archive page?
- Is it possible to set archive.php instead of index.php to display blog?
- Using is_page_template inside loop
- How to declare a variable in a loop and make it available in the template file
- Query users and count totals based on meta values
- Adding a second loop breaks everything
- How to get all multi-select user meta values and add them to an array?
- Archive: Lists itself
- Is “the loop” a template tag?
- Get top Page IDs from menu and cycle through their child pages on a scroller
- Show a list of user posts in the user admin page
- Deeply Nested Menu Loop with Twig using Timber [closed]
- Search – Check if post is a page on search page
- WordPress with woocommerce custom query
- Get Sticky User in user loop based on user role
- Alternative layout the loop
- Cant pull in featured Image
- Template included with plugin doesn’t return all posts for custom taxonomy
- Structure and Display Content from Multiple Pages on Single Page
- Creating a archive for taxonomy terms, not the term results
- Making a specific page wordpress compatable that is not index
- Default Template infinite loop of Title
- Secondary loop cuts off at 10 posts?
- Need a conditional to test if title of parent page matches title of child page
- Fake Single WordPress Post (Page) Loop
- query_post while (have post) get_template_part()?
- Display all existing members
- Combine Query and Select Database to create directory loop
- get all page templates
- Load featured article once in a loop
- wordpress showing all posts instead of date range
- Redirecting posts in WordPress to a specific page
- strange parse error when including a loop template within another template
- How to implement template file and the loop
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- Same posts within a paginated page
- How can I create an entirely new, separate display of posts?