Archive

Articles taggués ‘Wordpress’

What To Do When You Are Locked Out of WordPress Admin (wp-admin)

04/12/2023 Comments off

Locked-Out-of-WordPress-AdminThis past weekend, we had a user who was locked out of WordPress Admin panel of their site. While we had written numerous articles covering each specific issue, we realized that we should combine all of them at one place to make it easier for others. In this article, we will show you what to do when you are locked out of WordPress Admin (wp-admin), so you can regain access to your site.

There are few reasons why you could be locked out of WordPress admin, so let’s take a look at each of them one by one. Hopefully through this process of elimination, you will be able to figure out the solution for your problem.

Error Establishing Database Connection

Are you seeing this error on your entire site? The reason why you get this error is because WordPress is unable to establish a database connection. This could happen for various reasons. It could happen if your database got corrupted for some reason. It could happen if your web hosting server is having some issues. If this is your issue, then please refer to our guide on how to fix the error establishing database connection in WordPress.

White Screen of Death

Are you seeing a white screen on your WordPress admin? This issue is often referred to as the WordPress white screen of death. It usually happen because you exhausted the memory limit. It could be caused by a poorly coded plugin or theme. It could also be caused by unreliable web hosting. If you are seeing this error, then please refer to our guide on how to Fix the WordPress white screen of death.

Incorrect Password Issue

Sometimes, even when you are typing the correct username and password combination, you won’t be able to login. When you try to reset your password, you never receive the email. This can happen if you were a victim of a hack. We would recommend that you reset your WordPress password from phpMyAdmin.

This method can be a bit overwhelming for new users, but this is your best bet.

Lost Admin Privileges

Sometimes, you may be able to login to your WordPress admin, but you don’t see any of the admin functionality. For example, no plugins, no themes etc. This could happen if your user permissions were modified. Often this happen due to a hack. Hackers would infect your site, and then delete your admin privileges. In this case, you should add an admin user to the WordPress database via MySQL (phpMyAdmin).

PHP Errors (i.e Syntax error, unexpected function etc)

These PHP errors usually happen when you are pasting the code from a website. Often beginners use the built-in WordPress editor from their dashboard. While that feature is pretty handy, but if you don’t know what you are doing, then it can be a disaster. If you pasted a code from a website which locked you out of your WordPress admin, then the first thing you need to do is take a deep breath. Now the only way to fix this issue is using a FTP program (How to use FTP). Once you have installed the FTP program, login to your site. Go to the theme file that you modified. Most likely it was the functions.php file. Now get rid of the code that you added in there. Re-upload the file, and you should be good to go.

Before you go on the site and comment “this code broke my website”, please refer to our beginner’s guide to pasting snippets from the web into WordPress. This is just to prevent you from looking like a fool on the web. Often its hard to admit that the mistake might be yours, so make sure of that first before you point the finger at someone else.

Hopefully after going through all of these possible scenario’s, you have already fixed your site. If one of these solutions helped fix your issue, then please let us know in the comments. If you have a solution that is not mentioned in this article, then please share it in the comments as well.

 

Source: wpbeginner.com

Categories: Logiciel Tags:

How to Fix the WordPress White Screen of Death

04/12/2023 Comments off

WordPress-White-Screen-of-Death1If you have been using WordPress for a few years, then you have encountered the white screen of death at least once. The WordPress white screen of death is one of those extremely annoying problems like error establishing a database connection. The reason why this issue is frustrating for users is because it locks you out of your WordPress admin panel. Because there is no error output in most cases, you are left clueless to figure out what is the issue. The worst thing about white screen of death is that sometimes it will only affect a certain part of your site. For example, you may only see the white screen of death on your WordPress admin while everything else works fine. In other cases, you may only see it on a specific post whereas everything else runs just fine. In this article, we will show you how to fix the WordPress white screen of death by looking at a few possible solutions.

Note: Before you make any changes to your site, make sure you have sufficient backups.

Why do you get this error?

Majority of the time when you see a white screen of death, it means that you exhausted the memory limit. This could be caused by a plugin that you may be using that is not functioning properly. It could also be caused by a poorly coded theme that you are using. It could also mean that there is an issue with your web hosting server. Since the problem can be caused by any number of things, it may require a lot of troubleshooting.

Does the problem occur on your other sites?

If you have multiple sites, then the first thing you should do is to make sure that the white screen of death is happening across the board or just on this one domain. If the issue is with all of your sites, then it is a strong indicator that your web hosting provider is having some issues. However, if the issue is only with one of your sites, then this could be an issue with a plugin or theme that you are running. If the issue is only happening with a single post or page, then you know it is definitely a problem with your specific site.

Increasing the Memory Limit

Usually this issue happens because your memory is being exhausted. Use our tutorial on how to increase PHP memory in WordPress.

Disabling All Plugins

If increasing the memory limit did not help, or if you have a high memory limit like 256M or 512M, then you need to start troubleshooting. In our experience of troubleshooting this issue, we have always found that the issue is either with a specific plugin or a theme. Let’s go ahead and disable all the plugins.

Use these instructions on how to deactivate all WordPress plugins at once.

If this fixes the issue, then enable one plugin at a time to get to the bottom of the issue.

Replace Theme with a Default Theme

If the plugin troubleshooting doesn’t fix the issue, then you should try replacing your current theme with a default twenty ten theme. The best way to do this is by backing up your theme folder. Then deleting the theme. WordPress will automatically fall back to the default theme.

Alternatively, you can go in your phpMyAdmin and update the database tables in wp_options table. The following table names would have to be updated:

template, stylesheet, and current_theme. Change the value to twentyeleven.

If this fixes the issue, then you should look at your theme’s functions.php file. If there are extra spaces at the bottom, then you should consider fixing it. If you are using a poorly coded function in your theme’s functions.php file, then it can cause this as well.

Other Fixes

If none of the above fixes it, then you should try to re-install a fresh copy of WordPress. While it is unlikely, but it is always possible that a core file may have been corrupted.

You can also use the WordPress debug function to see what type of errors are being outputted. Add the following code in your wp-config.php file.

error_reporting(E_ALL); ini_set('display_errors', 1);
define( 'WP_DEBUG', true);
 

Once you add this, the blank screen will now have errors, warnings, and notices. These may be able to help you determine the root cause.

Sometimes, you may have access to the backend, but the front-end of the site has white screen of death. This can happen because of a caching plugin. Simply empty your cache.

If you have a white screen of death only on a very long post page, then you should also try to clearing cache. Another trick that we have found to work is increasing the recursion and backtrack limit. You can paste the following code in your wp-config.php file. Or in some servers you will be required to modify your PHP.INI file.

/** Trick for long posts */
ini_set('pcre.recursion_limit',20000000);
ini_set('pcre.backtrack_limit',10000000);
 

We understand that this is a very frustrating error, and we hope that one of the tricks above fixed the issue for you. What have you tried that seemed to work for you? If you found another solution to work, then please let us know. We would be happy to expand on this resource, so others do not have to waste as much time finding a solution.

 

Source: wpbeginner.com

Categories: Logiciel Tags:

How to Set a Minimum Word Count for WordPress Posts

30/11/2023 Comments off

minimum word count wordpressMinimum Word Count

Do you run a blog with multiple authors? Then, you probably have wondered how you can set a minimum word count for your posts in WordPress. In this article, we will share with you a snippet that lets you set a minimum Word count for your WordPress posts. If a user tries to publish a post that is too small, then it will return an error telling them the post is not long enough.

Simply open your theme’s functions.php file and paste the following code:

function minWord($content)
{
	global $post;
	$content = $post->post_content;
	if (str_word_count($content) < 100 ) //set this to the minimum number of words
	wp_die( __('Error: your post is below the minimum word count. It needs to be longer than 100 words.') );
}
add_action('publish_post', 'minWord');

You may change the minimum number of words from 100 to whatever you like. You can also customize the error to make it helpful.

Source: wpbeginner.com

Categories: Logiciel Tags:

How To Configure Redis Caching to Speed Up WordPress on Ubuntu 14.04

09/10/2023 Comments off

Introduction

redisRedis is an open-source key value store that can operate as both an in-memory store and as cache. Redis is a data structure server that can be used as a database server on its own, or paired with a relational database like MySQL to speed things up, as we’re doing in this tutorial.

For this tutorial, Redis will be configured as a cache for WordPress to alleviate the redundant and time-consuming database queries used to render a WordPress page. The result is a WordPress site which is much faster, uses less database resources, and provides a tunable persistent cache. This guide applies to Ubuntu 14.04.

While every site is different, below is an example benchmark of a default WordPress installation home page with and without Redis, as configured from this guide. Chrome developer tools were used to test with browser caching disabled.

Default WordPress home page without Redis:

804ms page load time

Default WordPress home page with Redis:

449ms page load time

Note: This implementation of Redis caching for WordPress relies on a well-commented but third-party script. The script is hosted on DigitalOcean’s asset server, but was developed externally. If you would like to make your own implementation of Redis caching for WordPress, you will need to do some more work based on the concepts presented here.

Redis vs. Memcached

Memcached is also a popular cache choice. However, at this point, Redis does everything Memcached can do, with a much larger feature set. This Stack Overflow page has some general information as an overview or introduction to persons new to Redis.

How does the caching work?

The first time a WordPress page is loaded, a database query is performed on the server. Redis remembers, or caches, this query. So, when another user loads the WordPress page, the results are provided from Redis and from memory without needing to query the database.

The Redis implementation used in this guide works as a persistent object cache for WordPress (no expiration). An object cache works by caching the SQL queries in memory which are needed to load a WordPress page.

When a page loads, the resulting SQL query results are provided from memory by Redis, so the query does not have to hit the database. The result is much faster page load times, and less server impact on database resources. If a query is not available in Redis, the database provides the result and Redis adds the result to its cache.

If a value is updated in the database (for example, a new post or page is created in WordPress) the Redis value for that query is invalidated to prevent bad cached data from being presented.

If you run into problems with caching, the Redis cache can be purged by using the flushall command from the Redis command line:

redis-cli

Once you see the prompt, type:

flushall

Additional Reference: WordPress Object Cache Documentation

Prerequisites

Before starting this guide, you’ll need to set up a sudo user and install WordPress.

  • Ubuntu 14.04 Droplet (1 GB or higher recommended)
  • Add a sudo user
  • Install WordPress. This guide has been tested with these instructions, although there are many ways to install WordPress

Lire la suite…

Categories: Logiciel Tags: ,

How To Turn Off Post Revision In WordPress 2.6

03/10/2023 Comments off

One of the irritating feature for me in WordPress 2.6 is the post revision. I am the only author of my blog and hence this feature is useless to me.

Just in case you are wondering how post revision works, whenever a post is edited, a new row will be created in wp_posts table. Hence if your posts or pages got edited 10 times, you will have 10 new rows in wp_posts table.

In no time your wp_posts table will be filled up and the post ID will be huge.

To turn off this feature, add this following code to wp-config.php:

define('WP_POST_REVISIONS', false);

You can also delete all post revisions by running this query in phpMyAdmin:

DELETE a,b,c  
FROM wp_posts a  
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)  
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)  
WHERE a.post_type = 'revision'  

Be sure to backup your database first before performing any queries in phpMyAdmin.

*UPDATE* Auto Saves does not create a revision of the post.

*UPDATE 2* Updated SQL query from Andrei Neculau as the previous query does not delete from wp_postmeta and wp_term_relationships tables.

*UPDATE 3* There is a proper way of cleaning up Post Revisions as mentioned by kitchin in Deleting Post Revisions: do NOT use the a,b,c JOIN code you see everywhere. I like his method more than the SQL query above.

Source: Lester Chan’s WordPress Plugins

Categories: Logiciel Tags: