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
- Why is wp_head() creating a top margin at the top of my theme header?
- Should `get_template_directory_uri()` be escaped?
- How To Add New Option Types To Option Tree?
- Automatic Updates For Private And Commercial Themes?
- What can I hook into after_setup_theme?
- add_image_size is scaling, even though crop is set to true
- Problems with Layout inherit in theme.json
- How to use bloginfo( ‘template_directory’ ) in array
- Should I update my _s theme?
- Setting a Default ‘Theme Location’ When Creating a Menu
- How to set page template on front using starter content?
- Different Admin Theme – Based on Role?
- Finding Page Template and Displaying Content
- Override Constants in Child theme
- How do I update WooCommerce template files in my theme? [closed]
- How to correctly add JQuery in a WP theme?
- Check if password protected post is visible
- What is the best way to handle multiple calls to get_template_directory_uri() and similar functions?
- how to change a theme slug
- Same theme name issue with wordpress repository theme
- Removing feeds from header using a function?
- I want to get the home root path
- How to add code in the content area in a WordPress theme?
- Change the template of multiple multisite pages at the same time
- Translation Issue with WordPress Theme Check in comment_form function
- Using esc_url with a hard coded url
- Broken template went invisible
- WordPress theme switcher
- Limitations when modifying wp_title with a filter
- How to edit theme functions file to modify pagination?
- WP_bootstrap_Navwalker_issue [closed]
- correct tags for validating input types
- How to remove header image in Twenty Eleven theme?
- Renaming a theme so it aids SEO and the theme used is hidden
- Dynamic menu links after header title
- Is there any tool to find lines of codes responsible to generate front-end HTML elements?
- WordPress 3.8 Backend Admin Color Scheme add more scheme how to do?
- Theme thumbnail in dashboard
- How to change the theme directory uri for localhost?
- Will my site get messed up when the wordpress theme updates if I edited the html code in the editor to change footer?
- How to correctly enqueue the parent and child theme stylesheets in the creation of a child theme? [duplicate]
- featured content: which area does this cover [closed]
- Which cache is kicking
- searchform.php doesn’t work properly
- Customizer: get_preview_url() inside customize_save_after hook
- How to add custom meta box when you have a custom page template file
- Password protect a custom template
- Adding Bootstrap to WordPress TwentySixteen Theme
- Load different single.php templates according to post layout selection
- Is there a way to switch to another theme?
- New to WordPress – Read the Codex, Other Docs; Still Confused
- Confused by the behaviour of “front page” / “home” templates
- When trying to set title, not sure how to edit it for different pages
- Post archives link yields a 404 Not Found
- Get video from the post on homepage
- static front page ONLY for certain themes?
- WordPress Themes Directory: Template which hits the standards?
- How to change a local wordpress installation xml export file urls? and change them to what if you don’t have a live website?
- Any way to change/add to the theme name dynamically?
- Let user to upload multiple time
- Different WP Rest API custom endpoints across different themes
- Different templates for each category level
- register_theme_directory() sees custom themes directory, but blank frontend
- Child theme in separate WordPress Install
- How to show children pages as array
- How to create multiple pages in a client theme?
- Using Customizer value in an external PHP file inside a theme
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- Theme automatically inserting “more” tag on every post
- How get the 10 most viewed pages (not post)
- Using wp_enqueue_script with social media buttons?
- Purchased Theme to Custom Made Theme? [closed]
- How to make website with many template that active [closed]
- Image Size wrong during upload
- Correct way to make a custom block theme responsive
- Is there a block to print post link standalone in a block theme?
- How to make a multilingual wordpress site to be translated one-to-one without much effort and without using translate?
- Is there a way to have WordPress autodetect page templates in the page-templates directory and any sub-folders?
- My wordpress site memory exhausted more than 1GB trying to debug with default
- Theme template file for a specific custom taxonomy