This function doesn’t take any params, so there is no nice way of doing it.
But of course you can do this PHP way using output buffering 😉
ob_start();
wp_head();
$var = ob_get_clean();
Related Posts:
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- Change dns-prefetch to preconnect with correct protocol
- Add footer.php to WordPress child theme
- Header has extra HTML block at top before my code
- How to safely remove the footer (twentytwenty)
- action hook wp_head higher priority as all other plugins/hooks
- Where would I place `wp_footer();`?
- Remove meta description on certain pages
- wp_head function not outputting
- Copyright info change – Corporate Plus Theme PHP [closed]
- Sidebar not appearing in footer, but it appears everywhere else!
- My website is not showing Footer section
- How do I properly code my footer? See example
- How to style injected code in header section?
- How do you remove header sitewide from mobile only?
- switch_to_blog() + do_action(‘generate_footer’) not working in multisite
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Add a top bar to a wordpress theme without editing the header.php file?
- Using Javascript On Page – Header and Footer Now Missing
- Add my footer menu to the header
- Add function to head “no product found”
- Switch position of elements in the footer [closed]
- Not able to add new item in wordpress home page
- Load admin bar without wp_head or wp_footer [duplicate]
- Links in footer section
- How to implement conditional PHP in Footer
- How can a ‘scripts’ directory be hooked into wp_head();?
- Particular meta tag – viewport – insertion when dealing with plugin
- Why is my footer missing [closed]
- Require Credits Footer
- footer doesn’t display
- How to modify default tags in wp_head()
- Execute a PHP Function when a Block is used and access it’s attributes
- What is the best way to define constant options for a theme?
- WordPress redirect redirecting too many times or not at all
- Can’t retrieve element with WordPress default @fetch_rss();
- set post limit at load more ajax wordpress
- I have a snippet to redirect all users to a maintenance page. How do I exclude users with admin role?
- php esc_html_e with an html link inside not working
- How to filter custom taxonomy term name, slug, and description?
- An audio player that showcase a random song from playlist every 24h [closed]
- how to prevent wordpress admin from logging in via woocommerce my-account page
- get_the_ID() in the footer returns wrong value
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- Trouble inputting variable into WP query
- How to get the last category name of a child category?
- Add html link in functions.php files of the theme
- How can I add a UTM tag with PHP code to pick up the post slug dynamically in the UTM?
- How do I include SVG file used as featured image?
- Use value from Ajax call in PHP function
- require_once() if a product in woocommerce contains a tag [closed]
- the_posts_pagination() not working in wpquery
- Automatic excerpt is not shown with the_excerpt() command
- Using ob_start and ob_get_clean with wordpress shortcode
- Change “No Comments” link to “My String” on Blog Post (Find Snippet in Code or use CSS, PHP Solution) [closed]
- Return product description
- How to add the sidebar to all the pages except the home page? [closed]
- Header not properly displaying on archive.php
- Custom meta box values are not getting saved for my custom post type
- Get the last 5 products from each category
- How to say if meta_value is greater than 0 in an array?
- Getting users with a specific meta data and then querying their posts?
- Why does the post_type_link hook everything twice?
- Adding a tag_ID column into Categories inside the admin dashboard?
- How to pass a variable into an add_filter() function?
- locale filter function running multiple times
- Multiple requests external data api dynamic block gutenberg
- Why does the Woocommerce grouped template prints the unpublished products?
- Woocommerce with Lazy Load php and ajax
- Adding conditional text to a PHP Shortcode Template
- How do I get the content excerpt of the recent post?
- How to check $_GET isset for a parameter and value? [closed]
- How to deal with too many $_POST variable conditions from ajax request at backend? [closed]
- Making your own custom post views count
- Save Custom CSS file in the upload folder dynamically?
- How to use two meta_compare in an array?
- How to update and save user metadata on page visits?
- Verify if a category is the child of another category
- How to remap one of the TinyMCE Advanced Editor button to open the wordpress media library?
- Simple AJAX notification when the new post is added to the database
- How to optimize update_post_meta?
- Warning: in_array() null given in PHP function
- Contact Form 7 – Replace database configured form template with a static file
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Why can’t I return a value from $wpdb->get var?
- How to get User Time Zone in WordPress?
- How to hook a logout funtion for specific usr role in wordpress?
- Redirection after submitting duplicate comment
- Convert code – not work
- Fix error Gravatar alt
- HTML Special Characters in URL string [closed]
- how to save checkbox data for custom setting?
- How to remove sidebar primary widget on Mobile on category page [closed]
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- Upload multiple files in randomly generated folder using wp_upload_bits
- Is it possible to change content in my PHP file from WordPress dashboard
- ACF put a comma after the last repeater field value [closed]
- Create page template via functions.php?
- Loading two post layouts for the same post with different url
- Code snippet to show current php version inside “At a Glance” box in admin