Monthly Archives: December 2021

Your Small Business Website Does Not Need WordPress

Don’t get me wrong, I still love WordPress.

We at Kiboko Labs have built several successful plugins and themes for WordPress. Most notably WatuPRO, the Chained Quiz, Namaste! LMS, Arigato PRO, Hostel PRO. We will be very happy if you use our plugins.

For the more than 10 years actively developing plugins, customizing apps and fixing sites, I know most of the WordPress weirdness by heart. We can still do almost everything with it. If you need help with WordPress, I’ll be happy if you get in touch.

WordPress is still one of the most affordable ways to get a non-trivial small business web app developed.

However… in most cases…

Your Website Does Not Need It

WordPress still powers a huge part of the websites. As of 2021 it powers more than 1/3 of the websites on the internet! Everyone is using it.

If you contact a web agency to have a website developed, most of them will suggest you to use WordPress. Why?

  • Because everyone is using it.
  • Because this is what they know.
  • Because this is what they like.
  • Because this is what they love.
  • Sometimes it’s because this is how they can charge you more.

Do you notice that there is nowhere “you” in the above reasons?

That’s because it’s usually about them.

But Why Not Use it?

Photo by Ferenc Horvath on Unsplash

  • It’s not as user-friendly that they want you to believe. All these menus, plugins, taxonomy, Gutenberg block editor, tools, is that user friendly?
  • It’s bloated. Sorry, WordPress, I love you, but that’s the truth. It used to be a tiny piece of software for blogging. Now it’s a huge software full with functions that you’ll never need.
  • It can be slow. Even if you cache the front-end, the back-end of some crowded with plugin WP sites is slow as hell.
  • It has to be constantly updated or you risk your site being hacked.
  • It can be costly to develop and maintain. What is advertised as easy and “almost free” quickly becomes bloody expensive as soon as you want something “out of the box”. Heck, even installing a theme is not always easy.

Then What?

Some companies (most of these that will not suggest you to use WordPress) will tell you that you need a powerful CMS or a “no-code tool”. Webflow, Drupal, Craft CMS, Flutter CMS, Plone, Joomla, Wix…

These are all good tools.

You likely don’t need them either.

Some companies will offer you custom development with cutting-edge technologies ( buzzwords). Laravel, Django, Rails, Node.js, React… “you’ll love to deploy our custom kubernetes orchestration of Java based microservices glued with Rust and Goland code…”

These companies may be good developers. Maybe they are even great.

But your teacher’s or plumber’s website does not need any of this.

This is over-engineering a simple problem.

Photo by Shane Rounce on Unsplash

Just because you want to have a contact form or even a booking calendar does not mean you need huge and costly software installed.

Yes, some small businesses do need a CMS. Some do need complex web based apps. These will benefit from custom development or a customized WordPress.

Some will blog regularly – these businesses will benefit of using WordPress or a similar CMS.

Many small business owners think they need a blog or a news section. They believe they will write regularly and will get search engine traffic because “content is king”.

“I need a blog. I will write a lot. I will get free traffic to my blog from the search engines”.

You don’t need a blog. You won’t write a lot (if at all). You won’t get free traffic from the search engines.

Most of these blogs and news sections stay stale. The owners write 3-4 posts and then stop. They are busy with their business. And that’s good because writing a blog does not bring traffic. Not anymore at least. Believing you’ll just write some content and users will come and find you is so 2010.

Simple, Light and Static. Or Mostly Static

That’s what your dentist’s / plumber / teacher / laywer / … site needs.

Simple and clean.

clean desk

Photo by Samantha Gades on Unsplash

Static, the heck?! It’s 2022?!

Exactly because it’s 2022.

I’m working on web development since around 1999. There was no Twitter yet. There was no Facebook. There was no Gmail.

I built sites in Notepad. I built sites in Frontpage. I built sites in Dreamweaver. I’ve built sites in plain HTML. I’ve built sites in HTML + CSS and JavaScript. I’ve built sites with Perl / CGI scripts. Then PHP. Then Joomla, WordPress, Drupal, Laravel, you name it. I’ve seen the advantages and disadvantages of all.

Your small business 10-pages site with a contact form does not need WordPress. It does not need any CMS or a framework.

It needs good old static HTML and maybe some PHP.  Hosted on a cheap shared host, files uploaded with FileZilla. No deployment required. Usually no database required.

But this means someone has to code it!!!

Let me tell you a secret – creating a site always needs a professional even if you use a “no code” tool or a CMS. Unless you are fairly good at setting up WordPress and designing a theme you will always need the services of a web development company or at least a freelancer. If you want your site to be professional and secure, of course.

So then what are the benefits of going static instead of using WordPress or another CMS?

  • It’s more affordable. Yes, you hear me right. You may pay $1,000 at the beginning. Sometimes even less for a 7-8 pages website. And then hosting + domain will be about 50 bucks per YEAR. Maybe you’ll need a couple of changes here and there across the year. It’s super easy to do small changes in a HTML file! It’s easier than learning a CMS, trust me. But in case you are totally non-technical and don’t want to touch any HTML files or not to mention PHP, that’s OK. You can pay for them and probably that would be 50 bucks per change a couple of times in the year. Compare this to a managed WordPress hosting which, just the hosting, often starts from $300 per year.
    The developers will tell you that you can do your changes yourself. They won’t tell you how easy it is to break something, to have something misaligned, to be unable to set a font size properly or a border around image. And you’ll end up paying again, but every change will be more expensive because we have to write a custom shortcode or maybe that widget will break or, oh, this does not fit the theme, let me find you a plugin – this one is good, it costs only $98 per year… You get the idea.
    Unless you change the content on your site frequently and cannot change it yourself, having a static or semi-static site is much much cheaper.
  • Static sites are faster. Nothing beats static. Nothing. Even a fully cached WordPress is slower. And then you have the problems with cache not purging when you need it to purge, with the caching plugin breaking your site, displaying odd errors, serving outdated images, and so on.
  • The code can be much cleaner. “Can be” because not all developers write good code. But still it’s much much easier to figure out what’s wrong when everything on the page is in one file, maybe with an included header and footer.
  • There is no bloat. No hundreds of JavaScript files you never use and have no idea what are they for. No CSS from different plugins.
  • They do not require updates. If your site uses PHP there is a slight chance that once in a few years you may need someone to have a look at some deprecated function. Even that is rare. I have PHP sites running without any work done on them for more than 10 years.
  • They are virtually unhackable (except when someone gains access directly to your server – which is also a problem for ANY other setup). A static website does not take any user input so there is no way to hack it. If you use some basic PHP for a contact form you need an OK developer that won’t leave holes in it. But this is nothing compared to the hackability of the big CMS-es.
  • They can be hosted anywhere and moved easily. There is no “deployment”. No dependencies. In most cases you don’t need even a database. So you’ll have no problems with setting up DB connections, getting DB connection errors, etc. Every host, even the cheapest, can host HTML and PHP files. Just download your files from the previous hosting service and upload on the new one.
  • Even a super junior developer can do some basic changes to a static site. Maybe you. Maybe your daughter. Maybe your brother. Maybe even your neighbor.

You get the idea. Just have a static site build, maybe with a contact form. If you are short on budget and time you can even use a cheap Bootstrap template and have the whole site built in 2-3 days for a few hundred bucks.

Ideally it’s better to have a custom design – this may take 1-2 weeks and cost $1k – $2k, but it’s a one time payment. And it’s still cheaper and faster than most other options.

What is Semi Static?

Most sites need a least a contact form. So you may need some programming, at least a little bit. Maybe you’ll want some price list updated from a CSV etc, you may even need a simple database with products. These things may get you closer to a CMS but while you are having only 3-4 dynamic sections it’s still better to have most of your site static and update only these settings rather than setting up a whole CMS like WordPress and having it “drive” your whole site.

Static Site Builders?

If you are closer to the web development community you may have heard about them. Jekyll, Hugo, Gatsby… They are great tool for generating static sites while still having a full powered CMS on a local installation.

They can be a great solution, because they have most of the advantages of static sites that I listed above. However installing and using these tools is a lot more technical and you either need to learn them yourself, or have a developer.

They are good options, however – it depends on your use case. If you are unsure and need help, feel free to contact me for a free advice.

How To Create a Related Posts Slider / Carousel in WordPress

This is a very common task: to show related content under a given post. Surprisingly there is no such built-in function in WordPress so here are two ways to achieve it.

The Easy Way: With The Free Shortcode Revolution Plugin

See in this video:

The plugin can be downloaded from the official repository.

The DIY Way: Code

If you are here to just get the work done, use the plugin suggested above. If you are looking to learn and / or need a custom solution, let’s see the code. It’s pretty simple.

First, let’s figure out what would related mean? You don’t have to create a complicated AI. The related posts can be selected from posts from the same category and/or with the same tags.

Let’s dive in the code. You will need to create a function – it could be a function right in your theme, which will then be used in the single-post.php template, or (probably better) you can do it with a shortcode. I’ll leave this decision for you.

global $post; // this is the currently shown post on the page		
if(empty($post)) return ''; // just make sure you don't run this in the wrong place where $post may not exist

// let's prepare the WPQuery parameters
$query = [];	

// We will add both tags and category as criteria. Feel free to use only one of them
$tags = get_the_tags($post->ID);
if(empty($tags) or !is_array($tags)) $tags = [];
$tags_arr = [];
// we can't use $tags directly as they come from get_the_tags() because they are objects. So we are filling the new $tags_arr
foreach($tags as $tag) $tags_arr[] = $tag->name;						
$query['tag_slug__in'] = $tags_arr;

// similar for categories
$cats = get_the_category($post->ID);
$cats_arr = [];
foreach($cats as $cat) $cats_arr[] = $cat->term_id;
$query['category__in'] = $cats_arr;

// Let's say we want 5 random posts. We'll select 6 and then strip to 5 just to make sure the current post is not included.
// You could use the "post__not_in" attribute for this but it has some specific which make us prefer to clean the unnecessary post in PHP.
$query['posts_per_page'] = 6;
$query['orderby'] = 'rand';
$wp_query = new WP_Query($query);
$posts = $wp_query->posts;

// here we'll cleanup the current post with array_filter and a closure
$posts = array_filter($posts, function($p) use($post->ID) {				
    return ($p->ID != $post_id);					
});

if(5 < count($posts)) array_pop($posts);

That’s it. You’ll have the related posts in the $posts variable. If you want to learn more how WP_Query works, check here.

Watch out for some pitfalls if you’ll use $posts outside of the loop. Or just use WP_Query -> have_posts().

From then on, you can use any JS slider and prepare the required JS variables.

In Shortcode Revolution we preferred to build a vanilla JS slider using most of the code from this great guide.

Alternatively you can use aready jQuery carousel plguin like Slick.

 

Oddness in The WordPress Posts Loop and WP Query

While working on the new version of Shortcode Revolution we faced a couple of confusing behaviors of WordPress functions. I’ll document them here and will keep adding such information. Hopefully it can help other developers and save them a lot of time and frustration.

Excluding posts from WP Query (using post__not_in)

There is a good comment here explaining that post__not_in wouldn’t work when used with post__in in the same query. This is a good note but our query did not include post__in and post__not_in was still simply ignored. I did not dig deep into the code to see why this happens – the conclusion was simply not to use it.

Here is an example how we get 3 random related posts in Shortcode Revolution:

$query = [];
// we add 1 to the default number of posts which is 3 or to the user-passed number or posts
$query['posts_per_page'] = (empty($atts['num']) or !is_numeric($atts['num'])) ? 4 : intval($atts['num']) + 1;       
$query['orderby'] = 'rand';

// getting the posts here
$wp_query = new WP_Query($query);
$posts = $wp_query->posts;

// now because this is "related posts" query, we don't want the current post to be repeated below it. So let's filter it out
// $post_id is a variable we have defined earlier in the shortcode and it contains the current post ID
// we are using array_filter with a closure here. You can do it inside a loop with a counter but this solution is more elegant
$posts = array_filter($posts, function($p) use($post_id) {				
  return ($p->ID != $post_id);					
});

// if the current post was not there we have one more than needed
if($query['posts_per_page'] < count($posts)) array_pop($posts);

 

So that’s it – you just get more posts than you need and then remove the unwanted ones in PHP.

Showing the excerpt outside of the post loop – get_the_excerpt

If you look at the documentation it sounds like you can call get_the_excerpt with any post ID and receive the excerpt for that post id. Good luck! You may get the proper excerpt (sometimes!) but won’t get the automatically generated “read more” link properly. The first version of our code was this and it did not work:

foreach($posts as $p):
   $background_image =  has_post_thumbnail( $p->ID )  ?  get_the_post_thumbnail_url($p->ID) : ''; 
   $excerpt = get_the_excerpt($p->ID);
.....

I intentionally did not use $posts as $post to avoid overriding the global $post variable but apparently this was wrong. Fortunately this comment gave me the hint how to fix it:

foreach($posts as $p):
   // yes, do override the global!
   $post = $p;
   // and you need to setup_postdata($post)
   setup_postdata($post);
   $background_image =  has_post_thumbnail( $p->ID )  ?  get_the_post_thumbnail_url($p->ID) : ''; 
   $excerpt = get_the_excerpt($p->ID);
......
endforeach;

And after the end of the loop don’t forget to reset the post data:

wp_reset_postdata();