WordPress Plugins

WordPress plugin development tutorials, helpful tips and guides about creating plugins for WordPress, by Mehdi Nazari

if you have something specific in mind, search in WordPress Plugins.

How to Remove a User Role from WordPress? (with example)

remove_role function in WordPress has a simple syntax. remove_role only gets a role name and if it exists, this function will remove the role from WordPress. We’re going to remove the “Contributor” role from our WordPress for an example.
WordPressWordPress Plugins

How to Check if a Post Exists in WordPress? (+Example)

WordPress has many ways to check a post’s existence by ID, title, content, date, and ETC. get_post and post_exists are two useful functions in WordPress collection that can help developers check the existence of any post. Let review these two functions and try their usage.
WordPressWordPress PluginsWordPress Themes

How to get Plugin Directory Path in WordPress? (+Example)

Referring to a directory can sometimes be challenging! to fix this issue WordPress has many functions to retrieve correct directory paths for developers. one of the functions is plugin_dir_path which is responsible for retrieving the current plugin directory inside WordPress.
WordPressWordPress Plugins

How to List All Authors in WordPress? (Shortcode Included!)

In this WordPress tutorial, We’ll list all authors using the wp_list_authors function. You can use this WordPress functionality in different scenarios. To make this function more useful, we’ll create a shortcode for printing all authors.
WordPressWordPress PluginsWordPress Themes

How to Check if the Current User is Administrator in WP?

User authentication is essential while developing WordPress. Detecting if the current user is an administrator in WordPress is not challenging, using the current_user_can function. This function is one of the most important security functions in WordPress.
WordPressWordPress PluginsWordPress Themes

How to Check if a Post is in Specific Categories? (+Example)

Checking if a post is in a specific category can help developers serve functionalities based on categories. For example, changing a post style or loading a specific file for it, when it’s in a specific category. the WordPress in_category can check if a post has a category checked for it or not.
WordPressWordPress PluginsWordPress Themes

How to Check if Content has a Specific Shortcode in WP?

Checking if a specific shortcode is available in content is an easy task to handle while developing WordPress. has_shortcode is the function available in WordPress that developers can use to check if the content has a shortcode or not! in this WordPress tutorial we’ll have a closer look at the WordPress has_shortcode function.
WordPressWordPress PluginsWordPress Themes

How to get Post Thumbnail URL with Custom Size?

WordPress generates different sizes for each uploaded image in the admin panel. Also, WordPress developers can register custom sizes for future generating. If you are interested in fetching a post’s thumbnail URL in custom size, read this article. I’m going to try registering new thumbnail sizes and retrieving thumbnails for each registered size.
WordPressWordPress PluginsWordPress Themes

How to Set or Get a Custom Field for a Post in WP?

Custom Fields in WordPress give developers the ability to store metadata on posts. Custom fields help developers avoid using extra tables in the database and use what is already available for plugin and theme development. In this tutorial, I will set a custom field on a post and retrieve its saved value.
WordPressWordPress PluginsWordPress Themes

How to get Page by Title in WordPress? (+Example)

Getting full details of a page by title is not that challenging in WordPress. WP has a function named get_page_by_title that is useful when a developer wants to retrieve page data from a specified title. For those interested WordPress developers, I’m going to try this function inside a working example.
WordPressWordPress PluginsWordPress Themes

How to get the Previous Post Link in WordPress?

Presenting Previous Post Link for visitors can generate more page views and increase conversion rate. WordPress introduced the get_previous_post_link function to help developers print the Previous Post Link easily and fast.
WordPressWordPress PluginsWordPress Themes

How to get the Next Post URL in WordPress? (Working Example)

WordPress get_next_post_link function helps developers to retrieve the URL of the next post when the user is currently inside one. getting Next Post URL is a great way of finding a related article for visitors to read. This functionality can increase page views if a developer uses it right.
WordPressWordPress PluginsWordPress Themes

How to get Publish Date of The Last Post in WordPress?

WordPress has two perfect functions to get Publish Date of the Last Post. get_lastpostdate and get_lastpostmodified functions are helpful when the developer wants to retrieve Latest Post’s Dates. In this WordPress tutorial for beginners, We will try these two functions in a working environment and check if they return what we want?
WordPressWordPress PluginsWordPress Themes

How to get Home URL in WordPress? (Usage Example)

get_home_url retrieves the Home Page URL of a WordPress website. get_home_url is one of the most used WordPress functions by developers when they want to use links in the development process. Let’s have a better look at this function with an example.
WordPressWordPress PluginsWordPress Themes

How to Count Comments on a Post in WP Programmatically?

The get_comments_number function will retrieve the number of comments for a post in WordPress. Do you want to check how many comments does a post has? Use the get_comments_number function with its easy syntax to get comments numbers for a post using ID.
WordPressWordPress PluginsWordPress Themes

How to Add a Custom Shortcode to WordPress? (+Example)

Shortcodes are helpful when WordPress admins want to run a function and return the result with a simple code. Developers can create a new shortcode for moderators to use when the process of calling a function is complicated or admins want to run a function on multiple pages themselves. Website moderators who do not know […]
WordPressWordPress PluginsWordPress Themes

How to Register a Custom Image Size in WordPress? (+Example)

Registring a New Image Size helps WordPress developers to generate different size images when the administrator uploads them on the admin panel. In this tutorial, we’ll have a close look at the add_image_size function which is responsible for registering a new image size in WordPress.
WordPressWordPress PluginsWordPress Themes

How to get Post Title in WordPress? (2 Examples!)

get_the_title is the core function responsible to retrieve Post Title in WordPress. We’ll try this function inside loops and with a specific post ID. This tutorial can be the only page you need to visit to learn how to print the title of a post when developing WordPress.
WordPressWordPress PluginsWordPress Themes

How to get WordPress Post Date using PHP? (+2 Examples)

Retrieving Publish Date of a Post in WordPress is an easy task to do. We’ll try retrieving post attributes using a specific Post ID or current queried post id to show you how to work with Post Dates in WordPress using the get_the_date function.
WordPressWordPress PluginsWordPress Themes

4 Special Ways to Unpublish a Post Programmatically in WordPress!

There are 4 ways to unpublish a Post in WordPress using PHP codes. In this WordPress tutorial for beginners, we’ll try unpublishing a WordPress Post using WordPress core methods.
WordPressWordPress PluginsWordPress Themes

How to Query WordPress Categories, Tags and Taxonomies

Learn how to list Categories, Tags and Taxonomies in WordPress using standard functions. In this WordPress tutorial for developers, we use get_categories, get_tags and get_taxonomies functions with working examples. After reading this tutorial, you can list WordPress categories, tags and taxonomies with all available filters.
WordPressWordPress PluginsWordPress Themes

WordPress Query Posts by Category, Tag, Custom attribute, and more!

Learn how to List Posts in WordPress using Category name, Tag name, Custom attributes, Post type, Publish date, Random posts, etc. For post listing in WordPress, we use get_posts function to retrieve any WordPress post with desired attributes.
WordPressWordPress PluginsWordPress Themes

WordPress Action and Filter Hooks Tutorial (+10 Examples)

In this WordPress tutorial for beginner developers, I will explain WordPress Actions and WordPress Filters and how you can use these WordPress Hooks in your theme or plugin, easy and understandable. This tutorial also contains +10 helpful examples for those who want to see this WordPress tutorial in action.
WordPressWordPress PluginsWordPress ThemesWordPress Tips

How to create a Hello World plugin for WordPress in 3 Steps

Creating a simple WordPress plugin is fast and easy.  in this short tutorial, I’m going to show you, how you can create a custom WordPress plugin and print “Hello world” text inside its admin page. this article also contains 10 helpful tips for beginner WordPress developers.
WordPressWordPress Plugins
Menu