- This topic has 3 replies, 2 voices, and was last updated 4 years, 5 months ago by Tom.
-
AuthorPosts
-
August 29, 2019 at 5:19 am #996213Matthew
Hey Tom et al.,
Recently began using GP on all of my client’s sites and so far every script/style issue encountered has been solved by this forum and your extensive documentation — thank you — except for this one….
Trying to remove the standard
<head>
on selected pages to create streamlined landing pages with minimal size, scripts and requests. Custom templates do not work becauseget_header()
pulls both<head>
and<header>
— neither does calling a header custom $name like this:if ( is_front_page() ) : get_header( 'home' ); else : get_header(); endif;
So I created front-page.php and a custom stylesheet to accompany it, however that does not work either.
if ( ! defined( 'ABSPATH' ) ) {exit;} ?><!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <link rel="profile" href="https://gmpg.org/xfn/11"> <link type="text/css" media="all" href="style-front.css" rel="stylesheet" /> </head> <body class="fp" itemtype="https://schema.org/WebPage" itemscope> <?php do_action( 'wp_body_open' ); do_action( 'generate_before_header' ); do_action( 'generate_header' ); ...etc...
Even using Cloudflare, AutoOptimize, and every speed trick in the book, GP front pages are around 2X slower and 50% larger than the same content displayed via front-page.php — active plugins include their css/js in the head even if they are not being used on that page.
To summarize, I want to continue migrating all of my clients from Genesis to GP but first I must find a way to preserve their home page and landing page speeds. Any suggestions on how to do this would be greatly appreciated, thanks!
Oh and yes, I have already spent several hours reading countless forum posts, including the following:
https://generatepress.com/forums/topic/how-to-create-custom-page-template-for-blog/
https://generatepress.com/forums/topic/remove-css-from-html/
https://generatepress.com/forums/topic/custom-css-classes-and-generate_do_element_classes/August 29, 2019 at 10:32 am #996557TomLead DeveloperLead DeveloperHi there,
Are you just trying to remove everything from the
wp_head
hook?If so, I wonder if this would work?:
add_action( 'wp', function() { if ( is_front_page() ) { remove_all_actions( 'wp_head' ) } } );
Let me know ๐
April 27, 2020 at 11:25 pm #1258949MatthewYup, Tom, that worked perfectly — thank you!
April 28, 2020 at 9:38 am #1259859TomLead DeveloperLead DeveloperNo problem ๐
-
AuthorPosts
- You must be logged in to reply to this topic.