Blog: R6D47: #100DaysOfCode (More Posts)
I continue to make steady progress making this little theme.
When I do my work, I mainly do it from 2 locations; my desktop PC or my laptop. I spent the first part of the day recreating the Database and WordPress credentials so I could carry on working on the Featured WordPress Starter project from my PC. So that there are subtle differences between the 2 versions but in principle, I should be able to carry on working interchangeably between the 2 locations.
One difference was that the first thing I found was that I didn’t seem to have the WordPress area set up containing my search Widget area. It’s probably not practical to keep switching between the 2 when working with database-dependent applications such as in WordPress even when done via version control. But I wanted to try and I did my best to make it work.
A case in point being that in my functions file I had code set up (I was sure) to specify a Widget area that should have appeared in the dashboard but it did not show up anywhere. I’ve been caught out a number of times by this where I think I’ve updated the git repositories so I can successfully move projects across the platform by simply typing “git pull” into the console.
Updates
Conditional Featured images – One of the tasks I wanted to finish today was to make sure there was an image in place to use when a featured image is not assigned to a post.
With some experimentation I got it done by writing a condition statement that checks exactly for the featured image.

The WordPress theme Screenshot image
<?php if( !has_post_thumbnail() ): ?>
<img src="<?php echo get_template_directory_uri() . '/img/logo.png'; ?>"
alt="main logo" title="main logo" id="main_image" />
<?php else: ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
Some methods put their own link tags and classes into their templates. Which caused a lot of issues with messed up markup that confuses WordPress into outputting attributes as text.
So it’s worth checking for this and removing any elements you add into your template files yourself. So remove any anchor tags of my own that I added to improve bugs in the markup in my templates.
Search Capability: I implemented search functionality which seems to be working. There is a template file for this but in this website, to make a search you do this via a widget rather than a link to the template. Search results go back to the home page. I got a bit confused with the developer documentation about whether to use search.php as a file name.
Eventually, I decided to use it, otherwise, the catch-all index.php template is used, and adding search.php is beneficial as it allows me to separate the templates when there is no search result returned. I can therefore output different search messages. So that is a definite benefit. And I’m looking forward to putting this knowledge into my other WordPress sites, like this one.


