I built a page with Elementor, and I want to use it as my home page. When I use a static home page with my theme, it still gets wrapped with the header, footer, and content container, which I don't want in this case.
I've built a simple front-page.php
template to try to just output the contents of this page.
<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php
$page = get_page_by_path( 'home' );
$content = apply_filters('the_content', $page->post_content);
echo $content;
get_footer();
?>
</body>
<?php wp_footer(); ?>
This works to output the content, but I don't get the styles and my posts widgets are MIA. How can I modify this template to also get the styles and so that all the widgets will be present?
functions.php
? Since you havewp_head()
here they should come through if they are. If not, you should remove them from being directly added toheader.php
and instead enqueue, so they can also appear here. As far as widgets, it depends on where your widgetized area is. Check your other template files and see - there is probably a sidebar (even if visually it's not a sidebar, WP calls it a sidebar) which you'll need to call in order to display widgets here as well.style.css
to figure out where it's coming from. If it's added properly you should see a call towp_enqueue_style
infunctions.php
. If it's just hard-coded as a<link rel="stylesheet">
somewhere, that's the problem with the styles. It's also worth inspecting the homepage itself to see whether there is any reference to the styles - it could be the stylesheet is loading but somehow you're missing a body class or something critical. Or could be the stylesheet tries to load but it's the wrong path.