How to correctly make edits to the core Headway Blocks

Please note: This is an Advanced tutorial.  Skills required: Creation of child theme and Advanced PHP.

You may find that you want to add a feature to one of the core Headway Blocks but when you edit the core files directly, those changes get overwritten when you update Headway.  Not to mention, editing the core files of Headway (or any theme) is not recommended.  If only there was a way to make those edits and keep them safe from updates.

Guess what?  There is. All you need is a child theme. Have one already? Let’s get started!

General Process

Make a copy of the files in the block’s directory that you want to make changes to.  In your child theme, create a folder called blocks, and then a folder for each block that you want to edit the core files.  You need to follow the same naming structure as what is found in the headway folder.

The Custom code block’s folder name is custom-code, the search block’s folder name is search and so on.

You’ll notice if you look in the block folders that some blocks have only one (1) PHP file and some have two (2) or more.

Blocks with one (1) PHP file to edit

  • The Breadcrumbs
  • Custom code
  • Embed
  • Footer
  • Header
  • Image
  • Pinboard
  • Search
  • Slider
  • Social
  • Text; and
  • and Widget area

So you’ll need just the one PHP file in your block’s folder.

For example, if I wanted to make changes to the header block, my child theme directory structure would look like this


Now you can make your changes to the header.php in your child theme and the changes you make will override the same file in the headway theme folder and your changes are protected from updates.

Blocks with two (2) or more PHP files to edit

Both the Content Block and the Listings Block have two main files to edit.

Content Block: content.php and content-display.php. There is also the comments-template.php where you can adjust how the comments display.

Listings Block: block-options.php and content-display.php. There is also the listings.php file but that handles only what elements are registered in Design Mode to edit and the location of some files.

The instructions are the same as the files with blocks with one PHP file to edit, except that, you need to make one other change in content.php for the content block and listings.php for the Listings block to get the child theme to look in the right spot for the display file.

Find this line in both files (make sure you are editing the files in your child theme, not the headway theme folder):

Content Block (Line 19):
require_once HEADWAY_LIBRARY_DIR . '/blocks/content/content-display.php';

Listings Bock (Line 23):
require_once HEADWAY_LIBRARY_DIR . '/blocks/listings/content-display.php';

Each of those lines (depending on which block you are editing) should look like this after you’re done require_once 'content-display.php'.  This tells the main block file to look in the right place for the display file, which is in your child theme, instead of in the Headway theme folder.

Note: If you want to edit the comments-display.php file too, you’ll need to change this line in content.php as well 
(Line 35) return HEADWAY_LIBRARY_DIR . '/blocks/content/comments-template.php';

The line should look like this when done:return 'comments-template.php';

And with that change, now you can make the edits to the block files as you wish and they are protected from Headway updates.

That wasn’t so hard, was it? Now, all you have to do is figure out which changes you want to make to the core blocks. Let the fun begin!

Spread the word!

One Response

Leave a reply

Copyright © 2016 Vesped Inc. All Rights Reserved. Proudly Powered by Headway and WordPress