Purpose and implementation of esc_url() in WP

esc_url() is a WordPress function used for sanitizing and validating URLs (Uniform Resource Locators) in order to make them safe for use in various contexts within a WordPress website. It helps prevent potential security vulnerabilities by escaping and validating URLs to ensure they conform to the expected format and are safe to display or use.… Continue reading Purpose and implementation of esc_url() in WP

Check if the Current User is the Administrator in WordPress

If we want to add functionality only for logged-in admins, this can be done with the current_user_can() function. By using current_user_can(‘administrator’) in an if statement, it’ll allow you to check if the current user is a site admin. Additionally, you can target a specific capability of a user.

Published
Categorized as Wordpress

Check if the User is Logged Into the WordPress Function

Here’s an example using the is_user_logged_in() function to display a logout link for logged-in users and a login link for logged-out users. We can use this in our theme’s function.php to add functionality specific to logged-in users. It will also work in our theme’s index.php, archive.php, single.php, etc for all kinds of functionality for logged-in… Continue reading Check if the User is Logged Into the WordPress Function

Published
Categorized as Wordpress

How to navigate between pages in Nextjs

In Next.js, a page is a React Component exported from a file in the pages directory. Pages are associated with a route based on their file name. For example, in development: pages/index.js is associated with the / route. pages/posts/first-post.js is associated with the /posts/first-post route. Create a New Page Create the posts directory under pages. Create a… Continue reading How to navigate between pages in Nextjs

categories fetch

To fetch categories, you usually need to request each category individually by its unique ID. So, to fetch multiple categories, you would need to make separate API requests for each category. We create an array of category IDs from the post.categories array. We use Promise.all to concurrently fetch each category by making individual API requests… Continue reading categories fetch

Published
Categorized as Wordpress

Create a plugin in WordPress

Create a New Folder:In the wp-content/plugins directory of your WordPress installation, create a new folder for your plugin. Name it something unique and descriptive. For this example, let’s call it test-plugin. Create the Main Plugin File:In the wp-content/plugins directory of your WordPress installation, create a new folder for your plugin. Name it something unique and… Continue reading Create a plugin in WordPress

Published
Categorized as Wordpress

How to change image on dark/light mode in Nextjs

In Nextjs we can change the images according to the dark mode or light mode. The display property can be used to toggle images according to mode change. Provided that the theme provider class is installed in your project, and that the dark /light mode is working fine, then the following code can be used… Continue reading How to change image on dark/light mode in Nextjs

Bbpress plugin

bbPress is intentionally simple yet infinitely powerful forum software.  bbPress is easy to integrate, easy to use, and is built to scale with the growing community. To install bbpress From your WordPress dashboard Visit ‘Plugins > Add New’ Search for ‘bbPress’ Activate bbPress from your Plugins page. (You will be greeted with a Welcome page.)… Continue reading Bbpress plugin

How to use ‘he’ library in Nextjs

he (for “HTML entities”) is a robust HTML entity encoder/decoder written in JavaScript. It supports all standardized named character references as per HTML, handles ambiguous ampersands and other edge cases just like a browser would, has an extensive test suite, and — contrary to many other JavaScript solutions — he handles astral Unicode symbols just… Continue reading How to use ‘he’ library in Nextjs