An error occurred while processing the directive wordpress как исправить

Решение ошибки

При разработке сайта работая с PHP документом, особенно с чужим готовым шаблоном, можно наткнуться на ошибку [an error occurred while processing the directive].

Когда мы такое встретили, пришлось потратить целых 20 минут чтобы решить эту ошибку. Ответ был найден на английском форуме. Виной этому оказался обычный закомментированный текст в HTML коде страницы под PHP скриптом.

Дело в том, что некоторые браузеры ошибочно считают, что PHP скрипт выполняется до сих пор. А закомментированный текст прерывает работу программного кода. Почему? Мы не стали вдаваться в такие подробности.

Исправление [an error occurred while processing the directive]

Скриншот лишь пример. С помощью режима разработчика найдите блок HTML кода, в котором появляется ошибка и удалите первый комментарий после PHP команды.

Надеюсь русскоязычная статья, поможет многим начинающих разработчикам сайтов решить данную проблему оперативно и не отвлекаться от более интересных задач.

исправляем ошибки вордпресс

Ошибка an error occurred while processing the directive довольно распространенная и с ней сталкивались многие в том числе столкнулись и вы, поэтому вы читаете данную статью. Основная причина ошибки заключается в SSI так как там есть функция которая некорректно обрабатывается для некоторых тем wordpress из за чего в разных местах сайта, в основном это footer и header появляется надпись (вставка) [an error occurred while processing the directive] над исправлением которой многие сломали голову в поисках ответа и реально действующего способа по ее устранению.Теперь благодаря нашей, понятной инструкции вы быстро и легко сможете устранить данную ошибку на своих сайтах wordpress без помощи специалистов.

В связи с участившейся проблемой связанной с указанной ошибкой в различных темах вордпресс, мы подготовили понятную для каждого инструкцию как ее устранить самим без создания резервных копий сайта, базы данных просто отредактировав немного код в  указанных ниже файлах, после чего проблема исчезнет навсегда и вы о ней забудете.

Подробная инструкция как 100% исправить ошибку [an error occurred while processing the directive] в теме WordPress.

Изначально вам нужно:

  • Перейти по адресу ( если вы будете редактировать файлы через панель хостинга или клиент например: FileZilla ):  /ваш-сайт.ru/public_html/wp-content/themes/ваша-тема ( если будете редактировать файлы через админку wordpress, то /внешний вид/редактор/ )
  • Далее ввести в поиск (по содержимому — тексту) кусок кода:  <!—# (если ваш хостинг не имеет функции поиска то найдите в вашей теме три файла — смотрите скриншот ниже)

ошибка 403 вордпресс

На странице 404 вашей темы ошибка: an error occurred while processing the directive будет выглядеть примерно так (смотрите скриншот ниже)

обновления записи в вордпресс

Что бы удалить данную ошибку вам нужно отредактировать код в указанных файлах вашей темы а именно:

  1. 404.php
  2. Header.php
  3. Footer.php

Откройте по порядку эти файлы и найдите кусок кода: <!—# который нужно изменить, вот например в файле header.php нужно убрать из кода решетку (#) (смотрите скриншот ниже) и сохранить файл. После этого ошибка ( an error occurred while processing the directive ) исчезнет в шапке темы. То же самое проделайте с файлом footer.php и ошибка исчезнет в подвале темы.

ошибка обновления записи wordpress

Что касается файла и страницы 404.php то здесь нужно будет удалить более одной решетки (#) смотрите пример на скриншоте ниже.

ошибка wordpress новый

Как видите решение для исправления ошибки [an error occurred while processing the directive] простое и теперь вы самостоятельно не прибегая к чьей то помощи сами сможете справиться с данной проблемой не только с настоящей но и возможно это пригодиться на будущее а так же для ваших знакомых, друзей у которых тоже такая проблема и они не нашли на нее ответа. В дальнейшем мы планируем публиковать различные и важные решения проблем по движку, темам wordpress, что бы не пропустить новости вы можете добавить сайт в закладки или сохранить его другим удобным для вас способом, все пока и легких решений любых проблем.

бесплатные скрепки

Поделись о нас с друзьями, кликнув по значкам ниже. Спасибо!

One of the main culprits for this issue is the file permissions for your scripts which might be incorrectly set up and prevent the server from accessing the files. These include the 666 and the 777 permissions, which you will need to change to either 644 or 755 to fix the problem.

Use the FTP editor to explore the functional WordPress sites. Check whether all files are set with the 644 permission and if the directories have the 755 permission.

The main reason for the “an error occurred while processing this directive” are faulty file permissions. Please note that this can be a very long fix, often taking hours and you will need FileZilla or other similar software.

First, you need to use a PHP script that will automatically set permissions for every directory on your website. This is the code to use.

<?
header('Content-Type: text/plain');
/*
* Recursively changes permissions of files and directories within $dir and all subdirectories.
* This script by XDude: http://www.xdude.com/
* Original script borrowed from http://stackoverflow.com/questions/9262622/set-permissions-for-all-files-and-folders-recursively
*/
function chmod_r($dir)
{
$dp = opendir($dir);
while($file = readdir($dp))
{
if (($file == ".") || ($file == "..")) continue;
$path = $dir . "/" . $file;
$is_dir = is_dir($path);
set_perms($path, $is_dir);
if($is_dir) chmod_r($path);
}
closedir($dp);
}
function set_perms($file, $is_dir)
{
$perm = substr(sprintf("%o", fileperms($file)), -4);
$dirPermissions = "0755";
$filePermissions = "0644";
if($is_dir&& $perm != $dirPermissions)
{
echo("Dir: " . $file . "n");
chmod($file, octdec($dirPermissions));
}
else if(!$is_dir&& $perm != $filePermissions)
{
echo("File: " . $file . "n");
chmod($file, octdec($filePermissions));
}
flush();
}
chmod_r(dirname(__FILE__));
?>

Now you can proceed to fix the “an error occurred while processing this directive” issue.

  • Backup all your files first.
  • Download this PHP script, which will automatically set the right permissions for all your files and directives (644 and 755).
  • You can freely edit the script and add other permissions of your liking.
  • Download the file, unzip it, and upload it to the root folder of your site.
  • Go to yourdomain.com/php_permissions_755_644.php

After waiting for a few seconds, you will be able to see a list of all files and directories – which means that the script works and that the permissions are now set.

Super-short version:

Download this PHP script to automatically set permissions of all directories to 755, and all files to 644, throughout your entire website.

It should get rid of the “[an error occurred while processing this directive]” error, and will fix many other annoying WordPress issues arising from file permissions.


Longer version:

I recently transferred my WordPress website to a new host.

After I deployed the backup, I got the lovely 500 Internal Server Error message the first time I went the website.

So, I replaced my super-customized .htaccess file with the WordPress default .htaccess file [download here].

That got rid of the 500 error, but then when I refreshed the page, I got…

[an error occurred while processing this directive]

Wonderful!

I poked around with FTP and noticed that the permissions of files and folders on the site had all been set to 666. I deleted all the files and extracted my backup using a different method … same result. “OK,” I thought. “Maybe the backup is bad, but I don’t have another one.”

Using FTP, I had a look through a couple other functional WordPress websites and noticed that:

  • all files had their permissions set to 644
  • all directories were set with 755 permissions.

I’ve found that incorrect file permissions are usually the reason why a WordPress website doesn’t work after moving it to a different server or host. Honestly, it’s my #1 frustration with WordPress and has, on occasion, ruined entire days for me. Usually, I just use FileZilla to set the permissions — but that can take hours!

So, I decided it was time to create (or find) a PHP script that would recursively go through every single directory on my site and set permissions automatically.

After a bit of Googling and testing, I was able to put a PHP script together which completely fixed the problem.

To fix this annoying issue on your website:

  1. Download this PHP script which will automatically set permissions of all directories to 755, and all files to 644.
  2. If you need, you can edit the script to change the permissions to any other value.
  3. Unzip it and upload the PHP file to the root folder of your website.
  4. Go to yourdomain.com/php_permissions_755_644.php
  5. After a moment, a list of files and directories will appear, which means the script has set the permissions successfully.

As always, I recommend deleting the script from your server once you’ve used it – it’s not the kind of thing you want to leave around for a hacker to exploit.

Script borrowed/hacked/modified from this Stack Overflow page.

Reader Interactions

If you used WordPress then you got too many errors like 500 Internal Server Error, wp-admin not Working, 500 error, Error establishing a database connection, and lots of others. Some errors are very irritating errors and “[an error occurred while processing this directive]” is one of them.

Some errors occur from file permission and some when you change your web hosting service. I get this issue when I change my hosting service and turn it into the new hosting.

I’ve recently transferred a new host to my WordPress website.

When the first time I went to the website I got 500 Internal server errors after creating a backup.

When I fix this error, I got 500 errors but after refreshing a page, I got “[an error occurred while processing this directive]”.

So I began to search for why this error occurs and how I fix it. After some research, I didn’t get any satisfying answers to my question.

I looked around with FTP and saw that all the files and folders allowed on the site were set to 666. I removed all the files and removed my backup using a different method … the same result “Well,” I thought. “Maybe backup is bad, but I do not have another.”

I looked through a few other functional WordPress websites using FTP and noticed:

  1. All files had their permissions set at 644,
  2. With 755 permissions, all directories have been set.

I’ve found that incorrect file permissions are usually the reason that the WordPress website does not work after visiting a different server or host.

I normally use FileZilla to set permissions— but it can take hours!

So I decided that it was time to create (or find) a PHP script that would reciprocally pass every single directory on my site and automatically set permissions.

After some research, I got the Php file script which completely fixed the “[an error occurred while processing this directive]” error.

You can fix this issue with the following options:

  1.  Download the Php Script, which automatically sets all directory permissions to 755, and all 644 files.
  2. You may edit the script to change the permissions to any other value if you need it.
  3. Unzip the Php script and upload the PHP file to your website’s root folder.
  4. Go to yourwebsite.com/php_permissions_755_644.php
  5. After a moment, a list of files and directories appears, which means that the script has successfully set the permissions.

As always, I recommend that you delete the script from your server once you use it – it’s not the kind of thing you want a hacker to use.

I hope you solve the [an error that occurred while processing this directive] error on your website. If you have any problems feel free to ask in the comments section. I can help you as soon as possible.

I get this script from premium.wpmudev.org

Hey there, welcome to WPbloggerbasic. I’m Ayush Singh, founder of this blog. I am a part-time blogger and affiliate marketer. I help Bloggers to get unique blogging, SEO, WordPress, and Affiliate Marketing guides to take their blog to the next level.

Понравилась статья? Поделить с друзьями:

Не пропустите также:

  • Если не застыл холодец как исправить ошибку желатином пропорции
  • Как найти адрес элемента памяти
  • Робот пылесос крутится на одном месте как исправить
  • Как найти конфликтующие приложения
  • Как найти место захоронения солдат

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии