• Skip to content
  • Skip to primary sidebar

Trisha Cornelius

Figuring it out as I go

  • Blog
  • Mental Health
  • Motherhood
  • Development
  • Design
    • Design Portfolio
  • Miscellany
  • About Me
    • Bucket List
    • About Me – old
      • Newer old about me :)
    • Privacy policy
You are here: Home / Development / Hello again WordPress development, I missed you

Hello again WordPress development, I missed you

Hello blog,

I have not done much website development lately. We had planned for me to go back to freelancing when Lucas turned one, but life happened with a ton of bricks, first with my mom-in-law getting admitted into hospital, and after we had got the ground back under us and said that I would start in the new year of 2016, with my dad’s  murder. And so, I have not really done much coding.

The other day on Facebook a blogger asked for a bit of help which I thought would take less than an hour to sort out, and so I offered my assistance. I am very glad I did.

First, I learnt that some WordPress themes that offer custom headers actually display only the image even if you have the option to show site-title and description enabled. So I went in and had a look at the header file and the functions file.

When I am doing any kind of modification to a site I generally go straight for a child-theme, and I usually write my own functions straight away. This time, I didn’t, I first had a look at the theme’s header file, which referenced this function:
function adelle_theme_heading() {
if( get_header_image() == true ) { ?>
<a href="<?php echo esc_url( home_url() ); ?>">
<img src="<?php header_image(); ?>" class="header-title" height="
<?php echo get_custom_header()->height; ?>" width="<?php echo
get_custom_header()->width; ?>" alt="<?php bloginfo( 'name' ); ?>"
title="<?php bloginfo( 'name' ); ?>" />
</a>
<?php } elseif( is_home() || is_front_page() ) { ?>
<h1><a href="<?php echo esc_url( home_url() ); ?>"
class="header-title"><?php bloginfo( 'name' ); ?></a></h1>
<p class="header-desc"><?php bloginfo( 'description' ); ?></p>
<?php } else { ?>
<h5><a href="<?php echo esc_url( home_url() ); ?>"
class="header-title"><?php bloginfo( 'name' ); ?></a></h5>
<p class="header-desc"><?php bloginfo( 'description' ); ?></p>
<?php }
}

So I saw that the problem was in the first few lines, with the fact that there was no reference to get_bloginfo(‘title’) and get_bloginfo(‘description’). As a personal preference I use the WordPress builtin functions of get_bloginfo which retrieves the information rather than simply displaying it as is the case of bloginfo , and that I was actually unfamiliar with before encountering this theme.

I don’t know what I was thinking when I decided to try and complicate matters and re-write this function, instead of creating my own and create a theme header file. But I spent a great deal of time banging my head against that wall before sanity prevailed and I created header.php so that this child theme consisted of: functions.php, style.css and header.php. The relevant portion of  my header ended up looking like this:
<h1 class="title"> <a href="<?php echo get_bloginfo('home_url')?>"
<?php echo get_bloginfo('title'); ?> </a></h1>
<p><?php echo get_bloginfo('description'); ?></p>
<div class="header_image"
<?php if( get_header_image() == true ) { ?> >
<img src="<?php header_image(); ?>" class="header-title" height="
<?php echo get_custom_header()->height; ?>" width="<?php echo
get_custom_header()->width; ?>" alt="<?php bloginfo( 'name' ); ?>"
title="<?php bloginfo( 'name' ); } ?>" />
</div><!--header image-->

I have realised that I enjoy the puzzles and frustrations of code not working and then being fixed and so I need to start doing it again.

Love and development,
Trisha

July 21, 2016 by Trisha Cornelius

Filed Under: Development Tagged With: custom header, development, wordpress

Reader Interactions

Primary Sidebar

  • Home
  • Blog
  • Miscellany
  • Motherhood
  • Mental Health
  • Development
  • Design

  · Copyright © 2018 · Patricia Cornelius ·

  · Built on the Genesis Framework for WordPress lovingly customized by Trisha Cornelius ·