[Resolved] Custom wp_head for custom pages, e.g. front-page.php

Home Forums Support [Resolved] Custom wp_head for custom pages, e.g. front-page.php

Home Forums Support Custom wp_head for custom pages, e.g. front-page.php

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #996213

    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 because get_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(); ?>>
    	<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" />
    <body class="fp" itemtype="https://schema.org/WebPage" itemscope>
    	do_action( 'wp_body_open' );
    	do_action( 'generate_before_header' );
    	do_action( 'generate_header' );

    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:

    Lead Developer
    Lead Developer

    Hi 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 ๐Ÿ™‚


    Yup, Tom, that worked perfectly — thank you!

    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.