Book Image

WordPress 5 Cookbook

By : Rakhitha Nimesh Ratnayake
4 (1)
Book Image

WordPress 5 Cookbook

4 (1)
By: Rakhitha Nimesh Ratnayake

Overview of this book

WordPress has been the most popular content management system (CMS) for many years and is now powering over 30% of all websites globally. With the demand for WordPress development and skilled developers ever-increasing, now is the best time to learn WordPress inside out. This book starts with simple recipes for configuring WordPress and managing basic platform features. You’ll then move on to explore how to install and customize WordPress plugins, widgets, and themes. The next few chapters cover recipes for content and user-management-related topics such as customizing the content display, working with content types, using the new Gutenberg editor, and customizing editorial workflow for building advanced blogs. As you advance, you’ll learn how to use WordPress as an application framework as well as a platform for building e-commerce sites. This WordPress book will also help you optimize your site to maximize visibility on search engines, add interactivity, and build a user community to make the site profitable. Finally, you’ll learn how to maintain a WordPress site smoothly while taking precautions against possible security threats. By the end of the book, you’ll have the tools and skills required to build and maintain modern WordPress websites with the latest technologies and be able to find quick solutions to common WordPress problems.
Table of Contents (16 chapters)

Restricting post/page content with shortcode

User management is an essential part of most advanced applications with WordPress. In such applications, different users have access to different content based on their capabilities. So, it's important to have features for allowing/restricting certain parts of the posts/pages based on the type of user. Shortcodes are the ideal way of restricting parts of the post/page content and allowing other parts of the content to all users.

In this recipe, we are going to create a shortcode that allows us to limit the content within the shortcode to members of the sites, as well as users with a specific user role.

Getting ready

Open a code editor and make sure you have access to the plugin...