You can use PHP’s output buffering. WIth this you can write a wrapper for the get_head()
function
function wpse251841_wp_head() {
ob_start();
wp_head();
return ob_get_clean();
}
You can then use this as
$data = array(
'wpHead' => wpse251841_wp_head(),
'postContent' => $post->post_content,
'postContentFiltered' => apply_filters( 'the_content', $post->post_content )
);
Reference: Output Control Functions
Related Posts:
- How to insert a logo in the header?
- Page template in two level deep folder
- Returning Variables back into a template
- Add social icons in a theme through custom admin menu
- How can a Theme Contain no Header File or Footer File?
- Why wp_head() function not loading style.css?
- create-guten-block in wordpress theme?
- Override template file i subfolders
- Single Page theme [closed]
- How do I get the trackback count of a post in wordpress without writing an SQL query?
- Template for landing pages
- How to add menù section to my WordPress template?
- Why still output /wp-content/themes/twentynineteen?
- Create theme for mobile phones and tablets only?
- Why is the `if else` not working?
- How to add cropped custom header image?
- How to create full header but keep content narrow
- What is the point of using the front-page.php template? [closed]
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- Sizing screenshot.png without losing aspect ratio
- How to add CSS class to custom logo?
- How to add custom css file in theme?
- theme path in javascript file
- What’s the difference between home.php and index.php?
- get_template_part vs action hooks in themes
- How to Link External jQuery/Javascript files with WordPress
- wp_redirect() – headers already sent
- Custom single template for a specific category
- The the_post_thumbnail without srcset?
- The proper way to include/require PHP files in WordPress
- after_setup_theme always runs
- Do I actually need to link my theme’s style.css in the theme files
- Why is wp_head() creating a top margin at the top of my theme header?
- Using classes instead of global functions in functions.php
- WordPress API Menu/Submenu Order
- How to move page template files like page-{slug}.php to a sub-directory?
- CSS classes for theme
- Add custom classes to anchor in wp_nav_menu
- How to remove search bar from a wordpress theme? [closed]
- Should `get_template_directory_uri()` be escaped?
- Get url of thumbnail from the media uploader
- My child theme doesn’t work Error: “The parent theme is missing. Please install your parent theme”
- Auto get_header and get_footer on every template?
- Caching and Versioning for rtl.css
- How To Add New Option Types To Option Tree?
- WP 3.4 – what action/hook is called when theme customisation is saved?
- What WP folder can I use to write files to?
- How to move page templates to custom folder?
- Are the WordPress Core CSS styles really all nessesary?
- Add a dropdown to theme customizer
- Should I use set_transient or update_option?
- Why doesn’t default WordPress page view use force_balance_tags?
- Theme Customizer : how to create multiple-level panel
- Why I can’t add a CSS style in this WordPress theme?
- Theme file for all pages that are a child of a specific page
- Allow Shortcode in Theme Customizer
- Where to post/upload the new theme for WordPress theme repository
- Is it possible to manipulate the list of page templates?
- Setting multiple default background images?
- Template for individual post designs
- How to make a theme with more than one CSS file?
- Is it good to rename theme folder downloaded from WordPress.org?
- How to control initial wp_head() output?
- Best practice way to implement custom sections into a WordPress theme
- Editing the custom background CSS
- What is the problem if I use CDN in my WordPress parent theme(built using bootstrap)?
- register_sidebar ignores ‘id’ and ‘class’
- Different wordpress 404 template for different post type [duplicate]
- What, specifically, should be included in theme_name_setup()?
- How to get gallery images?
- Is it possible to use line break in theme description?
- How does WordPress decide what template to use as frontpage
- Is the theme customizer slowing down my site?
- Display a different theme for not logged-in users
- Best practice (forward compatibility) for theme options
- Automatic Updates For Private And Commercial Themes?
- Why does my short code get executed before other content?
- Add colors to existing color palette without replacing it
- Child Theme not loading parent CSS
- What can I hook into after_setup_theme?
- Where do I find the functions triggered within a hook?
- What does “Do not deregister the jquery script in the administration area” mean?
- What is the best book to learn how to make themes for wordpress?
- Grab the first paragraph of each post
- Retrieve the template directory URI via global or get_template_directory_uri() every time?
- How can I see what template parts are being called for rendering the viewable page?
- Add a preview to a WordPress Control Panel
- add_image_size is scaling, even though crop is set to true
- Use of undefined constant FS_CHMOD_DIR – assumed ‘FS_CHMOD_DIR’
- How to show next Post Thumbnail image in WordPress using current post id
- use add_action(‘wp_head’) in a widget for generating dynamic CSS styles
- Symlink a directory to wp-content/themes
- Single Page WordPress Theme – Using page templates
- Add a #hash to the links in my custom menu
- Pushing updates to your premium theme
- Registering Sidebars and Sidebar Widgets. Sidebar Widgets Not Displaying
- Where can I find a good reviewed collection of Twenty Ten child themes?
- Problems with Layout inherit in theme.json
- How to check if post has any tag?
- What are WooCommerce starter themes? [closed]