Categories
General

A new challenge

After almost 11 years working for a diverse range of clients, I have decided to start a new adventure. Starting April 1st, I’ll be working full-time for Kinsta – Managed WordPress Hosting, as Marketing Manager Dutch Market.

Why did I take this step?

In 2009 I decided I wanted to serve my own clients and left my employer to start nostromo.nl. Since then I have served many clients and helped them improve their publishing workflow, developed new websites and grew their revenue. And now, I’m ending that.

I’m ending this because I feel like I’m loosing enthusiasm. As I have learned from the past, when I loose enthusiasm for my job, I’m going to postpone or even prevent certain tasks. And that will definitely not help my clients. They deserve the attention and enthusiasm they are used from me, nothing less. Also, I have been looking to get employed WordPress related companies, just talks, but the option of me working for another company than my own crossed my mind. That was a confirmation of my declining enthusiasm to run my own company and serve my clients.

Another option I had thought about was scaling my company. I have been working with numerous partners to deliver what clients wanted. Sometimes my own two hands just could not complete the task because of lack of time, technical challenges, or without me knowing enough about it the task. Hiring people/companies on a project basis to get more skills in certain areas worked great but just did’nt work out all the time. Sometimes (to be honest, most of the times) partners had no time because they were already involved in other projects. When that happens, I cannot close a deal with a client, because I simply can’t handle the extra workload.

And then, the final option I have thought about, hiring people. So nostromo.nl would not be a one man company anymore. Most of the times I have thought about this it only lasted a few minutes, then I stopped considering this to be an option. Mainly because I really like the flexibility of hiring partners on a project basis and do not like to have fixed employees.

So, all options I thought about did not spark my enthusiasm in a way that I wanted to seriously pursue them. Except one. The only option that gave me positive vibes, was working for an employer, or as a contractor.

Let’s go back to May 2019. I was walking to Berlin to raise funds for DonateWC, and I named it Walk To WordCamp Europe. Do you see who was the Golden Shoe sponsor (or in normal English, the main sponsor)? Yes, Kinsta. For many reasons the conversations before the adventure, and on WordCamps where Kinsta was sponsor, really gave me a good feeling about them and their services.

So, in December 2019 I decided to contact Kinsta to explore the possibility of me working for them. Well, the result of that is now known. I’m very happy that Kinsta allows me to start this new adventure and I’m looking forward to start the new job.

About Kinsta

Kinsta was founded in 2013 and their goal is be the best WordPress hosting platform in the world. Their team is remote-first with local hubs.

Performance is Kinsta’s obsession and by fine-tuning their servers they deliver maximum speeds. Only the best technology is used at Kinsta, from their server hardware to the software they run. No matter what development stack you use, they will always have the latest framework versions installed and up to date. Servers are powered by the Google Cloud Platform in 22 global data centers. Everything is interconnected over their premium tier network, designed to minimize distance and hops, resulting in fast and secure transport of your data.

These and much more features give customers an automatic scalable (when traffic spikes), easy manageable (with MyKinsta) and isolated (no performance impact of other sites hosted at Kinsta) WordPress hosting environment.

Take a look at the complete Kinsta Managed WordPress hosting features here.

What about nostromo.nl?

Since I’ll be going to work for Kinsta on a full time basis, I have no room in my schedule to deliver the same amount of service to my clients. As of March 1st, clients with a WordPress maintenance contract have been transferred to Buro Staal.

Rosanne and Annemieke from Buro Staal welcome their new clients.

Projects that are in progress will be finished as agreed upon and I will not accept any new projects. So basically, all services delivered from nostromo.nl will be stopped.

I want to thank all my clients for choosing me and nostromo.nl for their WordPress related challenges. (Of course I have already informed and thanked all my clients of this career move).

Wrapping up

Thanks for reading this post about my new challenge at Kinsta. I am looking forward to working for them, getting to know the team, meeting new contacts and making clients happy with the best Managed WordPress Hosting the world has to offer.

If you want to chat with me about Kinsta’s offerings, please consider this an invitation to reach out to me.

(Featured image by Robert Ruggiero on Unsplash)

Categories
Photos

Sunrise

Categories
WordPress Tips

Remove WordPress REST API links

When using the WordPress REST API, it might be needed to hide some WP REST API links from the page source to the outside world. Here’s how to do that.

Remove WordPress REST API Links

Let’s say you have added your own endpoint to the WP REST API, and do not want to publicly show it in the page source. There are two places the WP REST API link is added to the page source:

To remove these links we simply remove the functions that are hooked to wp_head and template_redirect

// Hide WP REST API links in page headers
remove_action( 'wp_head', 'rest_output_link_wp_head', 10);
remove_action( 'template_redirect', 'rest_output_link_header', 11);

Be aware that if REST API calls are done via AJAX, the browser shows the URL that is called, and it is visible to the public.

Bonus: Clear the WP-JSON index

If you have the WP REST API active, and don’t want people to see what endpoints are available, use below code.

// Hide WP REST API JSON index
add_filter('rest_index', 'nstrm_hide_wp_json_index');
function nstrm_hide_wp_json_index( $response ){
	return array();
}

If you want to further customize the WP REST API, use the plugin Disable REST API. This plugin disables all endpoint of the WP REST API and allows you to enable individual endpoints.

Screenshot of settings for the Disable REST API plugin
Settings of the Disable REST API plugin.
Categories
Photos

Breaking through the fog

Categories
WordPress Tips

Using FacetWP to show featured posts first

Want to show featured posts first in FacetWP results? Here’s how to do it.

The requirement

A client, using FacetWP to show posts filtered by a few Advanced Custom Fields, wanted to introduce featured posts. These posts need to be show first, and the rest of the results should be shown random.

Since FacetWP does an AJAX request every time a page is requested, or a facet is changed, we need to do something to prevent every request to show random posts, since that could show posts on multiple result pages.

Thinking about a solution

When a client drops an idea, actually any idea, my brain starts to think on how to implement this. With my experience I know some filters of my favorite plugins, but not all. So I draft a solution first.

Posts need to have an extra field, where the client can indicate a post is featured. Since the posts already have some ACF fields, I will add the featured field to it.

Next up is filtering the query to feed FacetWP the $post_ids in the right order, with featured posts first, followed by the other posts in a random order. I found out the facetwp_filtered_post_ids filter can be used for that.

Coding the solution

Here’s my favorite part of implementing a clients request. The actual coding. I start with writing the facetwp_filtered_post_ids filter function. This function has to return all post ids, in the right order, with the featured post on the front of the array.

The query arguments are self explanatory, except maybe for the meta_compare argument. LIKE is used here, becuase ACF stores the value of the uitgelicht (Featured) field in a serialized way. Be careful when using this, since this might give you unexpected results. In this case, the uitgelicht field can only have a value of 'ja' (yes), or '' (empty), so we can safely use this.

The we launch the query and get the results on line 16. NOw we need to remove the featured posts from the $posts_ids variable that is passed to this function through the filter. So we walk through the $post_ids and put the featured post id in the $matches array, and remove the post id from the $post_ids array. This gives us two arrays, $matches which holds the featured posts, and $post_ids which holds all other posts, without the featured posts.

Now we need to randomize the posts in $post_ids. As stated before, we don’t want to randomize on every request. With the client I discussed this, and came to a solution where results would be randomized every hour.

First I used the shuffle() function to randomize the $post_ids array. Sadly, this did not give me an option to keep the random order for a certain amount of time. So, here comes array_multisort().

We first set a duration in minutes, get the current time in minutes and subtract the duration from this time, to set the seed. Then we use the mt_srand() function to create seed. Next is seting the order and use that to re-order the $post_ids array with array_multisort().

The final thing we need to do in this filter function is merge the randomized post ids, together with the featured posts and return the array.

🚀 Performance tip: If you only need post ids, add 'fields' => 'ids' to the query args. This results in a query that only asks for ids, and not all other fields available in the posts table.

Apply the sorting to the FacetWP template

One final step is needed to get the results right. We need to set the order and orderby parameters on the FacetWP query for the template we want this to be used for. Here’s the facetwp_query_args filter. We add the query parameters to the original query parameters, and return the $query_args variable.

Here the code on Github, feel free to comment if you want.

Photo by Susan Yin on Unsplash

Categories
WordPress Tips

Preselecting a facet and hiding it automatically with FacetWP

In this short howto I will show you how you can preselect a facet, and hide it when the page renders.

Preselecting facets

For this case the client has a few facets that are filled by custom fields. The fields are specialism and level. These a are related to a custom post type Mentor.

To preselect a facet, we can use the facetwp_preload_url_vars filter. But, during execution the $post global variable is not available, so we need to first get the post. By using the get_uri() method of the FWP->helper class, we can get the uri. This can be mapped to the page name which a separate function nostromo_get_post_id_by_post_name() uses to get the post id.

When we have the post id, it’s possible to get the custom fields and use them as values for the preselects. We just have to add them to the url_vars[] array with the names of the facets.

At the end of the function we return the url_vars array, so the filter can be applied.

Hiding the preselected facet

To hide the preselected facet(s), all we have to is add a piece of CSS to the page, when the url_vars are set. Here’s when a hook comes in very handy. You can see the code on lines 25 and 36. You might need to tweak the CSS, or add some classes to make the CSS specific enough to work. Or use !important, just don’t tell anyone I gave you that advice.

Need technical help with WordPress?

Do you need technical help with WordPress? Please let me know.

Categories
Photos

Breakthrough

Categories
Photos

Blue and orange

Categories
Photos

Good morning

Categories
Photos

Spring is coming