Optimizing a WordPress site

Functions and shortcodes that are never used, eat some processor time at launch, as WP is registering their existence. Deregistering them would take up some additional (and minimal) processor time. Because they are loaded with functions.php they will reside in memory, either registered or deregistered. Which amounts to the same, as the code is never … Read more

How to combine multiple wp_insert_post into one in order to gain better performance

I would advise using wp_insert_post() and putting you text files into a CSV CSV Post Title,Post Content, “title”, “content”, “title”, “content”… PHP $path = “/posts.csv”; //require __DIR__ . “$path”; $file = fopen(__DIR__ . $path, ‘r’); while (($line = fgetcsv($file)) !== FALSE) { //$line is an array of the csv elements $post[“id”] = wp_insert_post( array( “post_title” … Read more

Namespaced shortcode?

Unfortunately, this is not how shortcodes work. Your solution will not reduce performance problems. At initialization the only thing WordPress does is make a list of all shortcodes that are being registered. If you look at the order in which WordPress is loading stuff you will see that plugins are loaded before the theme and … Read more

get_the_id, get_the_permalink, and get_the_title all with one DB call

These functions do not even call the database each time they are run. It just pulls them off the current post object that was returned by the database query that retrieved the posts. There’s nothing to optimise here. get_the_ID() and get_the_title() literally just return $post->ID and $post->post_title. get_permalink() is a little bit more complicated, because … Read more

Disable lazy loading on specific images

You can manage WordPress lazy loading with the loading parameter. Below code echo’s your image without using the lazy load function. echo wp_get_attachment_image( $image, $size, false, [ ‘class’ => ‘your-class-here’, ‘loading’ => ‘eager’ ] );

What is the most efficient way of implementing a notification system? [closed]

If you’re looking to get in to instant notifications without suffering from backlog, I’d looking in to both Node.js and Socket.io. You should be able to work with them both pretty easily and integrate w/ WordPress. The sample chat application on the Socket.io site isn’t a far cry from what you’d be doing. Basically an … Read more

is there a benefit in using a constant over get_stylesheet_directory_uri?

You can read up the source code of theme.php where get_stylesheet_directory_uri() is defined, inside you’ll see a str_replace() wich is consuming additional resources on each request. The best way to avoid this is to define a variable or constant that contains the path. In that case it is only called once. https://core.trac.wordpress.org/browser/tags/4.3.1/src/wp-includes/theme.php#L0

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)