How to find a key in an array by value in php
How to find a key in an array by value in php

To determine the key of an array by knowing its value, there are at least three possible solutions:

  1. You can use the well-known array_search function. We already used it earlier in the article on removing an element from an array.
  2. Use a loop to iterate through all elements of the array and compare values to identify the key.
  3. Use the array_walk function, imitating option 2.

read more...

How to determine user geolocation data
How to determine user geolocation data

To determine the user's location, we need their IP address and a database with a list of IP addresses and their associated geographic data. However, since we've already implemented a solution using a database in this article, today we’ll make the task slightly more complex and interact with an external service via its API to retrieve all the information we need — time zone, latitude, longitude, country, and city.

read more...

How to Create Your Own Status Post in WordPress
How to Create Your Own Status Post in WordPress

Why do we need custom statuses? As always, there are many use cases. I personally used them only once — to mark products that didn’t fall into any category when importing from the Yandex Market.

Below is an example of creating a custom post status. More about all the parameters can be found in the official WordPress Codex. I just want to highlight the following points:

  1. The "label_count" parameter must be defined using the "_n_noop()" function.
  2. Unfortunately, custom statuses are not automatically shown on the post edit/create page or in the post list table (when hovering over the post title to see quick actions).

read more...