Tag: WordPress

How to Override Yoast Meta Description

You can use wpseo_metadesc to have your own custom meta description. Just paste the following into functions.php. // custom meta description function filter_wpseo_metadesc( $wpseo_replace_vars ) { return “your custom meta desc here!”; }; // add the filter add_filter( ‘wpseo_metadesc’, ‘filter_wpseo_metadesc’, 10, 1 );

Continue reading How to Override Yoast Meta Description

WordPress Upload Problem: “The uploaded file could not be moved to wp-content/uploads/”

This error “The uploaded file could not be moved to wp-content/uploads/” may indicate a permissions problem with your WordPress uploads directory. If you don’t have shell access to your web server to set up directory permissions, you may need to contact your web host for support. If you have shell access, check the permissions for…

Continue reading WordPress Upload Problem: “The uploaded file could not be moved to wp-content/uploads/”

Getting a 404 After Moving WordPress to Nginx

You will need to edit the config file to instruct Nginx to direct requests to index.php. Open your config file. The default location is /etc/nginx/sites-enabled/default, however, if you followed an earlier guide setting up multiple domains in Nginx, your config may be located in /etc/nginx/sites-enabled/example.com. sudo nano /etc/nginx/sites-enabled/default Scroll down to the location / block.…

Continue reading Getting a 404 After Moving WordPress to Nginx

WordPress: Add custom class name to body for a particular template

To add a custom CSS class to the <body> tag in WordPress, add the following to functions.php. In the following example, we are adding the class my_custom_class to the template my_template.php and my_other_class to the template my_other_template.php. function my_custom_classes( $classes ) { if ( is_page_template( ‘my_template.php’ ) ) { $classes[] = ‘my_custom_class’; } if (…

Continue reading WordPress: Add custom class name to body for a particular template

Nginx: 502 Bad Gateway / xmlrpc.php. Is your site under attack?

I recently found my web server unresponsive with a “502 Bad Gateway”. The Ubuntu process viewer revealed the php-fpm service running at 100% CPU. On further investigation, the Nginx access log showed thousands of entries for xmlrpc.php from multiple IP addresses and spoofed user agents, one purporting to be Google Bot. /var/log/nginx/access.log 151.115.xx.xx – -…

Continue reading Nginx: 502 Bad Gateway / xmlrpc.php. Is your site under attack?

WordPress: Add custom CSS to admin pages and login page

You can add custom CSS to all admin pages by adding this function to functions.php (located in your theme’s subdirectory in wp-content/themes). functions.php function admin_css() { ?> <style type=”text/css”> h1 { color: red; } </style> <?php } add_action(‘admin_head’, ‘admin_css’); To add custom CSS to the WordPress login page, add the following to functions.php. This CSS…

Continue reading WordPress: Add custom CSS to admin pages and login page

WordPress: Get the file name from get_post_meta custom field

get_post_meta returns the ID of the post attachment. To get the file name of a custom field called pdf: $doc_id = get_post_meta( get_the_ID(), ‘pdf’, true ); $filename = basename( get_attached_file( $doc_id ) ); echo $filename;

Continue reading WordPress: Get the file name from get_post_meta custom field

WordPress “HTTP error” on large image file upload

I ran into a problem with WordPress on my DigitalOcean droplet recently. When uploading files larger than 10MB, WordPress would return a HTTP Error and fail to generate the thumbnail, although it did actually upload the file. Checking the Nginx error log I saw: /var/log/nginx/error.log 2017/05/05 23:11:48 [error] 2755#2755: *5 recv() failed (104: Connection reset…

Continue reading WordPress “HTTP error” on large image file upload