AW29 Create a wordpress theme

Share on facebook
Share on twitter
Share on linkedin

In this lessong task, I’m going to create a wordpress theme. The expected time consuption on this task is 12 hours. 12 hours! That’s crazy. However, it is possible to create a child theme and do some minor ajustments within that time frame. But to code a complete wordpress theme in 12 hours is impossible unless you’re on speed or is a highly experienced WordPress developer.

There are many ways to enhance or change WordPress. By adding hooks you can add (or remove) functionality or add, change or remove content from both front-end and backend. Some of them are mentioned in the lesson, and I feel really sorry for all my co-student that haven’t coded anything before. The examples are many and diverse, and here are some code I often use on my sites. On my drive I have a folder called snippets, where I save code I use often.

Disable the possibility to comments on the site

When WordPress is a blog, comments are useful. If it is a website it is not. This script disables the options to comment in the front-end, disables exsisting comments and removes the comment menu items in the back-end.

add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
// Remove comments metabox from dashboard
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
// Disable support for comments and trackbacks in post types
foreach (get_post_types() as $post_type) {
    if (post_type_supports($post_type, 'comments')) {
        remove_post_type_support($post_type, 'comments');
        remove_post_type_support($post_type, 'trackbacks');
// Close comments on the front-end
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);
// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);
// Remove comments page in menu
add_action('admin_menu', function () {
// Remove comments links from admin bar
add_action('init', function () {
if (is_admin_bar_showing()) {
remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);

Add Google Analytics to the site

Google analytics (GA) is the go-to standard for user tracking on a website. Until EU bans the use of GA, this script will add the GA tracking code to the site.

add_action('wp_head', function(){
	<!-- Google Tag Manager -->
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
<!-- End Google Tag Manager -->

add_action ('wp_body_open', function () {

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src=""
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

Move excerpt to top of page and rename it Ingress

I often use the excerpt in the beginning of a post template. By default, the excerpt form field is at the bottom and some plugins add extra fields to the editor, and pushing the excerpt text area further down. This moves it to the top – after the title.

function pixlweb_remove_normal_excerpt() {
    remove_meta_box( 'postexcerpt' , array('post', 'page') , 'normal' );
add_action( 'admin_menu' , 'pixlweb_remove_normal_excerpt' );

function pixlweb_add_excerpt_meta_box( $post_type ) {
    if ( in_array( $post_type, array( 'post', 'page' ) ) ) {
            __( 'Ingress', 'thetab-theme' ),
add_action( 'add_meta_boxes', 'pixlweb_add_excerpt_meta_box' );
function pixlweb_run_after_title_meta_boxes() {
    global $post, $wp_meta_boxes;
    # Output the `below_title` meta boxes:
    do_meta_boxes( get_current_screen(), 'after_title', $post );
add_action( 'edit_form_after_title', 'pixlweb_run_after_title_meta_boxes' );

Neither of these are visible to a user at the front-end, but is valuable to site owners.

More to explorer

AW33 Point of sales

A point of sales, or a point of purchase as it is sometimes referred to, is how your product is displayed in a sales location – a kind of exhibition

AW32 Branding and Packaging

Everywhere around us are items packed in something. Every item has it’s own set of requirement for the surrounding package, and a package has to be design around what it

AW31 Infographic and brochure

In this project part, the goal is to explore the visual language of a piece and create to coherent designs: one infographic and one brochure that has a common look’n