Advanced Custom Fields Demo

See what you can build with ACF

This text appears in the right side of Header.
To change this text for a specific Page, edit the Page and change the content.
  • Home
  • Custom Home Page-EC
    • Code for Custom Home Page
  • ACF Galleries
    • ACF Gallery Slider
      • Gallery Slider Page Template Code
    • Page with Magnific Popup Gallery
  • Flexible Content Layouts
    • Flexible Content Full-Width Page
    • Checkerboard Page
  • Create a Post
    • Front-End Posting and Editing
  • Blog
You are here: Home / Code for Custom Home Page

Code for Custom Home Page


<?php
/*
Template Name: Custom Home Page 
*/

/** Force the full width layout on the portfolio page */
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

//* Remove the site title
remove_action( 'genesis_site_title', 'genesis_seo_site_title' );

//* Replace title with custom field
add_action('genesis_site_title', 'acf_site_title');
function acf_site_title() {
  echo '<h1>'.get_field('heading').'</h1>';
}

//* Remove the site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );

/** Remove the standard loop */
remove_action( 'genesis_loop', 'genesis_do_loop' );

add_action('genesis_before_loop', 'condon_custom_loop');
function condon_custom_loop() {
      echo '<img src="'.get_field('hero_image').'" alt="hero image" />';
    echo '</div>';
    echo '<div>';
      echo '<div class="one-third first">'.get_field('column_1_content').'</div>';
      echo '<div class="one-third">'.get_field('column_2_content'). '</div>';
      echo '<div class="one-third">';
      $featured = get_field('featured_article');
      if($featured):
      // override $post
    $post = $post_object;
    setup_postdata( $post );
          echo '<h2>Featured Article</h2>';
          echo '<h3><a href="'.get_permalink($featured->ID).'">'.$featured->post_title.'</a></h3>';
          echo '<div class="excerpt">'.$featured->post_excerpt.'</div>';
        wp_reset_postdata();
        endif;
      echo '</div>';
}

genesis();

Based on Elliot Condon’s “Using the Advanced Custom Fields Plugin to Create a Custom Home Page in WordPress” tutorial.

Copyright © 2022 · Genesis Sample Theme on Genesis Framework · WordPress · Log in