WordPress User Search (Frontend) – The EASIEST Way!

I was recently been hired on Upwork (yes I still use it, following my rant), to extend on a ‘social network’ that is built with WordPress. This is my first BIG project, besides working on larger sites. The client had a developer working on it previously, but they couldn’t continue due to unforeseen circumstances – so they hired me.

At heart, I knew it was going to be a challenge, but I still applied. I have some development knowledge as far as building social networks, but not with WordPress. The best bit about this project was that I was being paid to learn. That made it more fun and fulfilling.

I built some really amazing functionality, like extending the follow profile code, blocking profile code and a user-generated newsfeed based on who they followed and who they had blocked.

But there was one task that really got to me. The user search functionality. As you know, WordPress’s default search.php file in any theme will just have a loop that will display only posts and pages associated with that search term.

And where I had never tackled something alike before, I decided to search on Google. Definitely not what I wanted, and I just knew that from the size of there snippets – that there was no need for lengthy code.

As a result, I gave up the searching and took a look at the good old WordPress Codex. Guess what, the answer was right in front of my eyes.

Thanks to WP_User_Query(), the search form now allows users to search for other users registered.

Let me show you.

Creating the form

The start of any search journey always begins with the search bar/form. I created a super-basic search form in the searchform.php file, which we can then call with get_search_form().

<form class="form-inline" action="<?php home_url( '/' ); ?>" method="get">
    <input class="form-control" type="text" name="s" id="search" placeholder="Search <?php get_bloginfo( 'name' ); ?>..." value="<?php get_search_query(); ?>" />
    <button class="btn btn-primary" type="submit"><i class="fa fa-search"></i></button>

I’m using Bootstrap 4’s framework for the amazing styling, but you can use whatever you want. I’m also using Font Awesome for their amazing icon library, again this is optional, but button values are so 2017 – in my opinion.

Creating the loop arguments

Once a user has searched, the default result page is search.php. So this is where we will need to put our loop. Using WP_User_Query() we can pull in user information associated with the search query.

<?php $s_query = get_search_query(); ?>

First, we need to assign the current searched term to a variable so we can use it in our WP_User_Query() arguments.

$args = array(
    'search' => '*' . esc_attr( $s_query ) . '*',
        'key'     => 'first_name',
        'value'   => $search_term,
        'compare' => 'LIKE'
        'key'     => 'last_name',
        'value'   => $search_term,
        'compare' => 'LIKE'

Now we can create our arguments. Firstly the ‘search’ parameter searches for a specific query, in this case, it will refer to what the user has entered into the search form. It uses a wildcard ‘*’, to ensure it searches the whole string for that search query.

For example, if we had a user called Harry and we searched for ‘ha’, it would still return Harry, because the wildcard searches for 0 or more characters. We also wrap this in esc_attr() to ensure that we do not input HTML from the search query into the loop.

We’re calling what we want to search for in the database using the ‘key’, ‘value’ and ‘compare’ parameters. We need to wrap them in an array as they come as a set, rather than individual parameters. You can see we’re searching the database for 'first_name' and 'last_name'.

Creating the loop

We’re not going to be an ordinary post loop, instead we’ll be using a foreach loop – yup, my new favourite WP loop.

<?php $user_query = new WP_User_Query( $args ); ?>

First things first we need to store the WP_User_Query() function within a variable and include our variable of $args within the WP_User_Query() function. Confusing, but we need to call this so we can pull the correct data associated with the search query within the loop.

<?php if ( ! empty( $user_query->get_results() ) ) {
    foreach ( $user_query->get_results() as $user ) {
        echo '<p><a href="' . home_url( '/' ) . 'user/' . $user->user_nicename . '/">' . $user->display_name . '</a><p>';
} else {
    echo 'There are no users matching your search.';
} ?>

Last, we have the loop. We need to create an if statement that checks whether there are actually results available to return for the search query. If there are users associated with that search query, return them and if not, then do something. Now we run the loop inside of the if statement, using foreach we can set the $user_query variable as $user to pull specific information within the loop.

Due to the client having Ultimate Member installed, the permalink structure for user profiles is completely different to the generic WordPress author profile pages. So, I had to use the home_url() function to help creating a nice anchor. Within that anchor, we call the users display_name which is generally their full name. It can differ.

To finish our first if statement for whether there’s data associated with the search term, we give people a little message letting them know that there aren’t any users matching their search.

And that wraps it up. Oh, one last thing – make sure you indent your code correctly – don’t make it messy for other people that are working on that project with you.


An upwork Rant

An Upwork Rant

Every freelancer loves Upwork. Well, I do anyway.

Let’s face it, every freelancer just starting out is getting their first clients via Upwork to build their portfolio for their offered services. Well, that’s how I started out.

Upwork is all fun and games, but obviously, there are some downsides, and it’s not Upwork as a company directly. It’s the jobs that Upwork allow to be posted by ‘clients’.

I’ve been using Upwork now for just over a year and I’ve built a pretty solid profile, in which, I’ve paid for the monthly membership to increase the amount of connects I get, to increase the likeliness of receiving extra work.

But after this year of working for clients all over the globe, the rage has built up and I need to let it out. Let’s rant.

1. Job value

One thing I find with clients posting their tasks and projects on Upwork, is that they think anybody in the right frame of mind is going to apply for a job that’s listed as $5 for ~10 hours work.

Clients need to understand that if the person who is applying for to undertake that task for them, is either:

  1. Incredibly unskilled and uneducated in that field
  2. Seeing the job as a starting point
  3. Not knowing their value
  4. Underselling their services

For example, if the client posts a job ‘complete WordPress build from scratch’ for $100, I hope everyone else that knows how to build a WordPress theme from the ground up will not apply.

Seriously, are you drunk?

Building a WordPress theme from scratch, depending on requirements is easily a 10 hour+ job. Not just for myself, but for most developers.

2. Not hiring a freelancer and leaving the job open

I’ve encountered this so many times and it’s such a waste of Upwork connects.

Clients will post a job with an in-depth description, speak to 5 freelancers about the job (including me) and then be unresponsive, leaving the job open and incomplete.

This is one of the things that annoys me the most because I like to follow up with the tasks I apply for and become an active candidate. I follow up twice until I just give up and search for other work.

The thing is, when I apply for a task or project on Upwork, and the client replies, I immediately stop applying for other jobs to ensure I don’t take on 2 tasks at once. Although I can multitask (duh, I’m male), I don’t think it’s right that each client gets divided attention.

Simples, don’t leave the job open for more people to waste their time and connects on if you’re not willing to continue recruiting for that task.

3. Contract terms and additions

Last week, I was in conversation with a prospect for creating a better version of a WordPress theme that had been built bespoke, in which the client was constantly sending over extra lists of work to carry out – although, he hadn’t stated this is the contract. I mean, the whole reason I applied for this job was to carry out the work you had asked initially.

This is the thing with clients who expect more for what it’s worth. I’ve had this problem numerous times in the past, and I’ll probably have it again next week. 7/10 jobs that you apply for, there’ll be a client who wants more, more, more  – the thing is, from a freelancers perspective, the only reason we took that job is to earn the money and build a portfolio.

There will always be clients like this, and there’ll be freelancers who are silly enough to fall for this. It’s called underselling yourself.

Don’t be that guy.


Even though I’m publishing 3 nags to the public about Upwork, it’s still an amazing platform for freelancers making money and clients receiving work from great freelancers. It’s just you need to be careful with the jobs you apply for, if the job description doesn’t specifically state the work you’ll be doing, don’t apply for it – only god knows what you’re getting into once you do.

Furthermore, don’t undersell yourself, it’s really not hard. If it breaks the bank to turn down a full WordPress build for $100, then there’s something seriously wrong with you or your coding skills aren’t up to scratch. It’s pointless spending X amount of time on doing X if there’s not enough income to pay for your time. Time is money, remember that.

From my perspective, all I can say is, don’t waste your connects on a job that you know further down the line will be shit. Use your instincts.

Fixing Duplicate Transactions in Google Analytics (Magento)

Magento is the fastest growing eCommerce platform on the web right now, but the built-in Magento analytics aren’t as extensive as we would like them to be.

I’ve been working on a clients site recently that is using the Magento platform, and they were having a huge problem with his analytics data, it seemed to be that the transaction was being recorded twice in Google Analytics per unique purchase.

This is very bad, why? Google Analytics relies solely on transactions (purchases) to provide other data. This other data includes revenue and when this isn’t being recorded accurately or correctly, it puts a spin on things from a business and an SEO perspective.

If you’re coming across these errors, then it could solely be server-side and your theme/template conflicting your Google Analytics set up. But hey, I haven’t seen how you’ve set it up but below is the quickest and easiest fix, that worked for me.

Fixing Duplicate Transactions

The reason you’re probably getting duplicate transactions is that you’ve most likely installed 2 tracking codes on your website, whether one be standard tracking and the other Universal Analytics, or both of them are Universal – still, it’s going to be firing and tracking it twice, causing the duplicate.

So in order to resolve and fix this issue, follow the tutorial below…

Firstly, log in to your Magento admin dashboard and hover over ‘System’ to reveal the drop down. Now select ‘Configuration’. We’ll now be in the System Configuration area where we can edit the core Magento settings.

Magento sales section in system configuration

Scroll down the left sidebar to find the Sales section, and click on Google API. The Google API is already built into Magento, so no need to worry if you think you haven’t got this.

Disabling Google Analytics tracking in Magento via Google API

Here, we’re looking to see if it’s enabled – if it is, disable it!

Note: Do not disable this if you don’t have a 2 transaction codes on your website, otherwise you’ll remove all tracking from your website.

Other fixes

Obviously, this may not work for you. It all depends on your tracking setup. This client of mine was using a Google Tag Manager plugin that also had Google Analytics tracking code attached, so it was conflicting.

If the above fix didn’t work for you, here are some other tutorials from experts to help you fix this issue:

  1. https://www.lunametrics.com/blog/2014/07/07/duplicate-transactions/
  2. https://www.simoahava.com/gtm-tips/prevent-repeat-transactions/

I hope this post helped you fix your duplicate transaction data in Google Analytics. If not, leave your website below and I’d be happy to take a look at it and coming up with the best way to fix.

WordPress is NOT Dead! – Why WordPress is Amazing in 2018

WordPress is undoubtably the most used Content Management System in the world for bloggers and business owners. Pretty much anyone and everyone who owns a website is using WordPress for their desired management of content.


Because WordPress is simply… amazing!

And, to even be asked the question, “is WordPress dead?”, is one of the most bizarre things I’ve ever heard since building with it, making clients happy with it and using it in general.

So, the answer is NO, WordPress is not dead. It’s alive and still making the internet a better place. Here’s how I see it, if WordPress is dead, blogging is dead.

Did you know, 74.6 million websites depend on WordPress for their website, whether it be a business or blogging website.

The thing is, WordPress can do pretty much anything you want it too, with, or without knowledge of coding languages, why?

  1. Plugins – WordPress comes with a plugin library with a quantity of 54,274 (and that’s off this second me writing this post), that allow you to extend WordPress’s core functionality.
  2. Widgets – WordPress comes with a pre-built section of widgets that allow you to perform specific functions, like displaying posts and menu’s anywhere on your site.

But that’s not all there is too it. Automattic (the company who created WordPress) are constantly working on new ways to improve the system with security updates, function extendability, usability, user interface and customisation. It’s a developers playground.

Of course, like any other platform there are some issues. In which, WordPress has a support forum for all users, whether you’re a blogger or a developer.

There are always going to be more pro’s than con’s with WordPress, because of way it’s constantly updated to evolve along with the internets standards – which it goes above and beyond.


The main thing about WordPress is that it’s open-source and anyone can use and edit its core files. With this, you’re free to use WordPress without having to pay for a single license fee.

Automattic created two versions of WordPress:

  1. WordPress.org – this public version allows you to download and self-host your WordPress site, for free.
  2. WordPress.com – this commercial version allows you to create a WordPress-hosted website via WordPress themselves, at a price.

For developers and site owners though, WordPress.org will always be the way forward as it gives you the most flexibility.


There are 50 employee’s working on improving security for WordPress, every single day. Which means, it’s pretty much impossible.

Obviously, along with any website there lies risk of intrusion – but that’s the whole point of their security team working round the clock to help keep our data and website’s secure.

If you’re not satisfied with WordPress’s core security, then there are a handful of plugins that will extend the security functionality. Namely:

All of the above have pretty much the same functionality, but all with the same intention – keep your site secure.

Designed for YOU

Before WordPress became free-source, WordPress.com was for simply for bloggers – so the user interface is easy to use and read.

The good thing about WordPress was that it was specifically built for you, not specifically to bloggers or developers. Everyone who is anyone can use it.


As WordPress is a free open-source software, you’ll need to to host the website yourself and buy a domain. Effectively, WordPress is cheaper to maintain than many other CMS providers like Drupal and Joomla, and the commercial version of WordPress.

You can do the math, but domain + hosting = CHEAP.


There are systems out there that cap your SEO efforts, namely Wix – in which, decrease the chance of a successful ranking in search results. If you’re an SEO and looking to encompass SEO into your website, then WordPress is your answer.

With WordPress coming with pre-built permalink and other SEO features, you can also extend on them using plugins. You can use a plugin like Yoast SEO to edit your meta data, OG and social data, sitemaps, breadcrumbs, etc.

Everything that an SEO will need to configure for on-page optimisation, you can do with WordPress and Yoast SEO.


WordPress comes with a library of professional designed themes, some free and some of charge. Did I mention there’s thousands? And even if they aren’t in the WordPress library, there are third party sites that have theme libraries too.

On this note, WordPress themes are a developer’s playground – literally.

You can build pretty much anything into your WordPress theme, with the help of a plugin or hard-coding it yourself. The possibilities are endless. Let’s take a look at this site for example, how gorgeous is that mega-nav? Powered by WordPress, developed by a genius.

I think that pretty much sums it up, WordPress is not dead and won’t be anytime soon. With Automattic constantly updating and upgrading the functionality, it seems like a rapidly-evolving CMS, that will never die out.

August 2017 Update

Hey guys!

So if you’re a regular follower of my blog and my social media channels, you’ll know that I’ve been really quiet this month. There are a few reasons for it, but the biggest is I’ve been super busy with family life and work. I’ve decided to start writing monthly updates to let people know what I’ve been up too, whether I’ve been too busy to post or not.

Here’s what I’ve been up too…

Rank and Rent

I’ve come up with this wicked plan to get 5 sites ranking in specific niches and areas by some point next year, then rent them out to business owners who are having trouble getting leads. In a way, I’m basically selling leads to the business by redirecting the leads over via call tracking.

Now, at the end of my Rank and Rent video I talk about a post coming shortly. This still isn’t out yet. Don’t worry, it will be – this will be published by the end of this week.

Stick that in your diary.

I won’t be updating you as to where I’ve got so far with month 1 of the plan due to creating separate content for the updates on both YouTube and this blog.

New web design project

I’ve had this one in the pipeline for a long time, and the client finally came through with the initial payment so the design process could begin. It’s something I’ve been super excited to work on for a long time as I’ve never worked on something quite like it.

There’s so much customisation with the functioning in the backend it’s unreal, and so far it’s looking pretty hardcore.

When this is done, this will free up so much of my working day fo’ sure!

Instagram marketing

For a while now I’ve had a little side project running with an Instagram account. I’ve been earning 1k per month for the past 2 months by getting people to sign up for paid tools and other services, which I’ve been promoting through my Instagram account.

You’re probably thinking, what!?!?

Truth is, even with my current follower count (57 followers), I’m still getting that recurring income. How?

Well… I’ll explain it to you in an eBook that you can download.

I’ve been writing an eBook on how to make this kind of money with your Instagram account which will be soon available. I’m giving away only 200 copies and there are not many spaces left, so if you want this FREE eBook, head over to my Instagram account and visit the link in my bio.

Local citations

As most of you know, local citations play a huge role in Local SEO. I’ve been doing a whole lot of these for the past couple of months – and they’re paying off amazingly.

Local citations are where your business is mentioned on other websites, for example, Yelp and Google My Business, in which, keeping the information consistent across these websites is a ranking factor. So it’s not the nicest job in the world playing with all that information and adding listings, but I prefer to do it single-handed rather than assigning it to my VA to do.

If you’re looking for the best local citation service, read my post.

New SMM & SMA client

I’ve recently been pushing out the Social Media Management and Social Media Advertising side of things with clients, and it just so happens… this month I got a new client wanting both of these services.

We had the initial meeting 2 weeks ago and we’ve already sat down and worked on a gold strategy on how to get more leads and more people interacting with their content. I’ll have some more information about this client soon, such as case studies, etc.

Things I can take away from this month

Plan time more efficiently. I’ve been taking every day as it comes this month and not planning anything in. I need to make sure that everything that I do is planned and set myself a time limit on tasks.

Stop taking days off. This month has been one of my worst months as a freelancer, probably because it was my birthday on the 8th. But, seriously, I took like 3 days off (mainly to recover) for my birthday. Ashamed to say the least.

Courses and eBooks are still workingThis month I released a landing page link for my new free eBook about Instagram marketing and within 24 hours almost 100 copies had been taken from the 200 that were there. Quality.

Well that’s it from me folks, see you in my next post. Any feedback? As always, leave it in the comments below and I’ll get back to you.