WordCamp U.S. 2018

Gutenberg, GraphQL

& Government

HOMEPAGE

  • Gutenberg Block Template
    • Fixed blocks that can't be moved
  • Hero Block
  • Recent News Block
  • Leadership Block

HOMEPAGE

add_filter( 'allowed_block_types', function( $allowed ) {
  global $wp_post_types, $post;
  if ( 'templates/home.php' === get_page_template_slug( $post->ID ) ) {
    $wp_post_types[ $post->post_type ]->template = [
      [ 'oshpd/homepage-hero' ],
      [ 'oshpd/latest-news' ],
      [ 'oshpd/leadership-cards' ],
    ];
    $wp_post_types[ $post->post_type ]->template_lock = 'all';
  }
});

Locked Gutenberg Block Template

HOMEPAGE

Leadership Block

HOMEPAGE

Leadership Block

query GET_CURATED_LEADERSHIP($postIn: [ID]) {
  leadership: staffMembers(
    first: 3 
    where: { 
      in: $postIn
      orderby: { field: IN order: ASC }
    }
  ) {
    cards: nodes { 
      ...LeadershipCard
    }
  }
}

HOMEPAGE

Leadership Block

HOMEPAGE

Leadership Block

query GET_CURATED_LEADERSHIP($postIn: [ID]) {
  leadership: staffMembers(
    first: 3 
    where: { 
      in: $postIn
      orderby: { field: IN order: ASC }
    }
  ) {
    cards: nodes { 
      ...LeadershipCard
    }
  }
}

HOMEPAGE

Leadership Block

fragment LeadershipCard on StaffMember {
  featuredImage {
    sourceUrl
  }
  name: title
  link
}

Event Listings

  • Complex Data Structure
    • Multiple Custom Post Types and Custom Taxonomy
  • Add Listings from Gutenberg

Gutenberg, GraphQL & Government

By Jason Bahl

Gutenberg, GraphQL & Government

Gutenberg, GraphQL & Government - WordCamp US 2018

  • 299
Loading comments...

More from Jason Bahl