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()
- How can i remove all html tags from get_the_content()?
- Using WP_Query – how to display something IF there are no results
- Custom SQL query to get List of posts with featured image url
- How to preserve PHP modifications while upgrading WordPress?
- Rename image uploads with width in filename
- Save selected item from dropdown menu in a meta box as a metadata value for a custom post type
- Problems migrating WordPress to localhost
- Best way of adding CSS which can be manipulated by the user via theme option panels?
- How to check if comments are paginated?
- Use Timber/Twig to pull an image by image ID [closed]
- Adding dropdowns to the tinyMCE editor
- How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?
- Change WordPress default registration error text [Error: This username is invalid because it uses illegal characters. Please enter a valid username.]
- How to make custom total price reactive in navigation
- PHP to Programatically delete a file
- Instantiate class to be available to all plugin functions
- Implement toggle switch for theme options in settings API
- ACF: how do I get the fields and its values of a specific group?
- Trying to place a custom field after the total section in the checkout page in woocommerce
- Find exactly what php files are responsible for each php process
- WordPress Multiple Navigation bars
- Adding a widget function into the php theme file
- PhantomJS with wordpress
- Call to undefined method – Download Monitor
- Conditional Javascript based on WP Version
- Underscore – Self hosted fonts
- Is it possible to return content, and then also continue to do other things?
- Does WordPress create a new Linux user when creating a new WordPress blog?
- How to sent a email outside WordPress?
- Can’t add script immediately after the opening tag on login page?
- page-slug.php not working but only for specific slug
- Redirect to a page for only logged in user
- Add 23 hours 59 minutes and 59 seconds to meta key before saving?
- How to turn each phone number within the $content to a telephone link?
- Creating custom page template from existing PHP site
- Storing content into a custom taxonomy
- WordPress Search
- WordPress pagination not working in search result page
- How to call custom function outside from the admin page?
- Pagination stays on same page for post category
- I get “Cannot modify header information – headers already sent” when I change my theme
- Fetching review value using wpdb class
- Create an array with all the links of the years’ archive (of a custom post type)
- Post form – AJAX won’t upload featured image – Plugin development
- Redux option doensn’t seem when include from functions.php
- Set all WooCommerce Products to Simple, Virtual & Downloadable
- Removing links from Grouped products
- How can i find wrong word in search box and replace with correct word
- admin panel – How to remove “delete” button from category editing page
- Like and Dislike Buttons on Post with Counter – Only allow one click per post per user session
- How to override WooCommerce Order Item Meta with data from Cart?
- Meta query not showing result properly
- How does WordPress rewrite URLS using its PHP scripts
- WordPress add_rewrite_rule
- Help on Wp_query to print an term
- Inserting other fields to existing registration form in a WordPress theme
- PHP drop down menu for my get_category child of
- add_rewrite_rule questions
- retrieve wordpress post-meta using php not wordpress functions
- Break a WordPress function to run in patches and re-continue
- Post content not showing some content
- custom data in url
- PHP-Code inside Href-Tag
- How to handle parent and child pages?
- Wrapping the_content() in Schema articleBody tag? [closed]
- How to create a container in php then customise it in CSS
- Execute scheduled cron with ajax call to wp-cron.php
- On profile update check if user is Subscribed to emails?