When I began to explore the WordPress theme code at my beginnings with WordPress, I came across a problem that I could solve only after a while. At that time I had no idea of minimalist web design, yet I wanted to stick to a minimalist web development habit, i.e. code less and have less files. While coding less can be grasped immediately as a saver of time, bugs and nerves, minimalist design is harder to understand in nature as it has to do more with arts. Even though now I am able to color some pixels on the screen about minimalist web design, it is not what I intend to discuss here. I want to share with you what I kept for a invention at the time my PHP grasp was very immature.
It was the case when I wanted to have most WordPress template files reduced in one as the case of the classic WordPress theme. In other words, I wanted to use only the index.php file which would do the role of home.php, singe.php, page.php etc. But I wanted to have a default excerpt option for all of them except singe.php and page.php. This made me have an hard coding time, but the pleasure of solving it was great. My “invention” is below:
<?php if ( is_single() || is_page() ) { the_content(); } else { the_excerpt(); } ?>
That’s it. I just wanted to share this with you and why not be a little helpful. I would love your feedback. Please, drop me a line. Thanks!