Changing permalink settings, throwing 404 error in localhost? Solution for Ubuntu with Apache
Wordpress , PHP / May 18, 2020

Changing the permalink settings from plane to other options like Month and name/Other can cause a 404 error while you are running your WordPress in Ubuntu with Apache localhost.  This error can be quite annoying and here are the changes you should make to get rid of this error. To change permalink navigate to settings->permalinks.     We are running your WordPress site from folder /var/www/html/testfolder/wptest     Step 1 – Enable mode rewrite in Apache

Provides a rule-based rewriting engine to rewrite requested URLs on the fly. Now after enabling, restart  Apache

          Step 2 – Modify the Apache Config file Apache config file is  etc/apache2/apache2.conf. Open the file using the following command.

Find the following lines in the config file

replace this with the following. The AllowOverride ride is changed to All and require is changed to all granted.

AllowOverride directive is used to allow the use of a. htaccess within the webserver to allow overriding of the Apache config on a per-directory basis. Require provides a variety of different ways to allow or deny access to a resource.           Step 3 – Restart Apache…

Disable WordPress comment box, on reaching a specific number of comments or if user already posted specific number of comments.
Wordpress , PHP / May 6, 2020

Imagine a use case in which the comment box has to be disabled On reaching a specific number of comments in WordPress post If the user already posted a comment For applying these conditions, the following data are needed Number of comments in a post Number of comments of a User in a WordPress Post   Obtain the number of comments in a WordPress Post To obtain the number of comments in a post, the following built-in function  get_comments_number, can be used.

    Obtain  the number of comments of a User in a WordPress Post To obtain the number of comments in a post, by the logged-in user, the following built-in function  get_comments, can be used.

  Navigate to the themes folder, comment_form  function in comments.php usually outputs the comment form. A condition has to be applied before calling this function.

  On using plugins, this might not work depending on the plugin For more information read the following documentation for built-in functions This approach helps in preventing spam comments.

How to display user – display name,avatar and logout button in WordPress : Example
Wordpress , PHP , Beginner , Snippets / July 8, 2018

To display user displayname , avatar and provide a logout button for a user in your wordpress site,we can use the following  five worpress functions. is_user_logged_in () –  Check whether used in. wp_get_current_user(id/email,null)  –  Get current logged in user get_avatar_url(userid) – Get avatar url for current user using userid wp_logout_url(url) – Logout and redirect URL home_url() – Get your home URL  

  Check below links to see documentation in full        

Share this page in social media platforms