Install error: preg_replace(): Compilation failed: shortcodes.php on line 309

Hi friends, I’m back on WPError again. I’m here to share a new experience on example I’ve faced today. I was hired to move WordPress WooCommerce web-shop based on Bazar WordPress template from one to another domain. On the first sight project looks quite simple we could say “ABC” job but several issues appear.

I did successful SQL and FTP backup and restored both on the new server, did required SQL changes trough the PhpMyAdmin and tried to run the site. Then received this error for the first time in my six years of experience.

Install error: Warning: preg_replace(): Compilation failed: unknown option bit(s) set at offset 0 in /home/public_html/wp-includes/shortcodes.php on line 309

warrning shortcodes 309

Website is broken, revolution slider didn’t work (WordPress was unable recognize and call slider name), none of custom template shortcodes were working and there was many more smaller issues and errors.

At first I tried with various things with plugins and setting but at the end I realized it could be PHP error. So I decided to try with downgrading PHP from 5.4 to PHP 5.3 version. New server was on Godaddy witch under the Cpanel have an option for Software/Services – Select PHP version.

software and services

As soon as I switched PHP to older 5.3 version all site errors and issues are gone.

Add custom post types to archives page

CPT ArchivesAfter we have added custom post types snippet into our functions.php we expect that our new articles under the custom post type to appear on archive pages, but they will not. It’s very logical from the developers side, WordPress maintain that sorting archives is for normal post types “posts”, and adding custom post types into categories and post_tags requires some custom code.

So, if you’d like your custom post types to show up in archive listings for your site’s standard tags and categories you can add the following code to your functions.php file:

Add custom post types to archives

[php]
/**
* Snippet Name: Add custom post types to archives page
* Snippet URL: http://wperror.com/add-custom-post-types-to-archives-page.html
*/

function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) {

// Get all your post types
$post_types = get_post_types();

$query->set( ‘post_type’, $post_types );
return $query;
}
}
add_filter( ‘pre_get_posts’, ‘add_custom_types_to_tax’ );
[/php]
Still if you wish to display only specific custom post types into archive pages of tags and categories you can replace the line $post_types = get_post_types(); with $post_types = array( ‘post’, ‘your_custom_type’ );.

Parse error: syntax error, unexpected T_VARIABLE in wpincludes /functions.php on line 192 WordPress 3.5

There seems to be a lot of people experiencing a problem after upgrading to WordPress 3.5

If you get the following error (or very similar)

Parse error: syntax error, unexpected T_VARIABLE in wpincludes /functions.php on line 192

Then it is believed your wordpress upgrade has been hacked.
This has now been confirmed as a definite hack. To confirm, YOUR WEBSITE HAS BEEN HACKED!

You can review this forum for help on fixing this error

Some people are simply replacing the functions.php file with a new copy of this file, however there is likely to be a number of files in your root directory (take a look for files that just start with a load of numbers)

It is recommend (strongly recommended) to fix this error permanently and to remove the hackers files from your website that you work through the following resources. (I can help if required but i do charge $100 for this as its a lot of work)

Ill update this post when a patch from wordpress is released or further advice is received.

Fatal Error: Allowed Memory Size Of Bytes Exhausted

This is a common error and its easy to fix.
You normally see this after adding a plugin or new theme and there just isn’t enough memory. To fix this simply create a file in notepad and add this line into it

memory_limit = 256M ;

Save this as php.ini
Now upload this to your wp-admin folder
Thats it, the error is fixed.

Watch this video to see how its done.

Did you find this useful? If so please take a moment to share this below, Thanks