How to display posts sorted by latest comments in WordPress
How to display posts sorted by latest comments in WordPress

WordPress (WP) has a universal function called `get_posts`, but unfortunately, it doesn’t work in 100% of cases. Sometimes, to get the desired result, you need to manually build an SQL query. I don’t really like doing that, since I don’t know all the ins and outs of WP’s internal mechanisms (such as where and when certain filters should be applied). But when the task requires it, you have to write custom SQL.

read more...

How to Change the Link Set in WordPress Meta Widget
How to Change the Link Set in WordPress Meta Widget

WordPress has a built-in widget by default called “Meta”. The functionality of this widget is quite simple. It displays a set of links that change dynamically depending on the user's login status. That is, whether the user is logged in or not. This widget displays the following links — site admin (or registration), login (or logout), post RSS, comment RSS, and WordPress.org.

In one of my projects, I needed to limit the number of links in the menu. I wanted to keep only the first two — registration and login — and remove the other three — RSS + WP — as unnecessary.

read more...

How to create breadcrumbs from post categories
How to create breadcrumbs from post categories

As you probably know, WordPress is a very widespread CMS — and people try to use it just about everywhere. Working on some projects, you can’t help but wonder: why use it here? Wouldn’t it be simpler and more efficient to use something built on a PHP framework? But trends are what they are — WordPress is used where it’s needed, and often where it isn’t.

Today’s post is not about whether WordPress should or shouldn’t be used in certain projects. Instead, you’ll learn how to generate a term array or build breadcrumbs for a post. It doesn’t matter what post type you’re using — a regular post or a custom post type — or whether the taxonomy is built-in or custom.

read more...

How to enable caching of adsense ads from google in wp-rocket
How to enable caching of adsense ads from google in wp-rocket

WP Rocket is one of the most popular caching plugins for WordPress, offering a rich set of features and flexibility.

WP Rocket has the ability to combine and minify JavaScript and CSS, generating a separate file for each. Additionally, it collects all inline JS/CSS from the site's HTML code and adds it to the aggregated cached files. This is certainly convenient, but in some cases — especially when used alongside other plugins — it can lead to errors or improper behavior.

read more...