WordPressThe website has created multiple classified directories. By default, all classified directory articles are allowed to be viewed by all visitors. How can I achieve this if I want unlisted visitors to only access specified classified articles?WordPress does not provide this function in the background by default. You still need to use code orplug-in unitrealization.The code shared below implements wordpress to restrict visitors from accessing specified classified articles.
Implementation code: In the currentthemeAdd code to the functions.php file of
1. When visitors browse pages other than the home page, if the category ID of the category directory of the article they visit is 3 or 2, "No Access Permission" will appear. If you don't want to pop up a prompt, you can use the wp_redirect() function to jump;
2. The 3,2 in the in_category (array (3,2)) code is the classification directory ID
WordPress restricts non login users to browse classified articles
118 people have bought
The download price of this resource isfiveelementBuy Now(VIP free)upgrade now
Professionally provide WordPress theme installation, in-depth localization, accelerated optimization and other website construction services. Please consult online customer service for details!