Monthly Archive: February 2020

Remove emoji function in WordPress

Problem: WordPress forced to add emoji function since version 4.2 and want to remove it.

Solution: In the theme folder that you are using, add below code to functions.php:

remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );

Auto-renew SSL certificate via letsencrypt in Cent OS 7

Problem: Want to auto-renew SSL cert via letsencrypt. I use letsencrypt-auto --apache -d to create SSL certificate.

Solution: first make letsencrypt program executable from anywhere since most of you just download a zip file from the Internet.

ln -s /opt/letsencrypt/letsencrypt-auto /usr/bin/letsencrypt 

then you can enter letsencrypt to trigger /opt/letsencrypt/letsencrypt-auto.

above command can eventually renew all certificates that about to expired.

Then add a record to cron job:

enter command crontab -e and add below content

0 0 * * 1 /usr/bin/letsencrypt  renew >> /var/log/le-renew.log

the command will trigger at 00:00 on every Monday. The renew record will save on /var/log/le-renew.log

9/4/2020: below is the create SSL command, just a note for me:

cd /opt/letsencrypt/
./letsencrypt-auto --apache -d

Change WordPress index page content without affect the widget section.

Problem: Want to change WordPress index page content from post to page.

Solution: First go to /var/www/html/[website]/wp-content/themes/twentyseventeen/index.php, follow below content

 * The main template file
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * @link
 * @package WordPress
 * @subpackage Twenty_Seventeen
 * @since 1.0
 * @version 1.0

get_header(); ?>

<div class="wrap">
	<?php if ( is_home() && ! is_front_page() ) : ?>
		<header class="page-header">
			<h1 class="page-title"><?php single_post_title(); ?></h1>
	<?php else : ?>
	<header class="page-header">
		<h2 class="page-title"><?php _e( 'Posts', 'twentyseventeen' ); ?></h2>
	<?php endif; ?>

	<div id="primary" class="content-area">
		<main id="main" class="site-main" role="main">
			if ( have_posts() ) :

				/* Start the Loop */
			//	while ( have_posts() ) :
			//		the_post();

					 * Include the Post-Format-specific template for the content.
					 * If you want to override this in a child theme, then include a file
					 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
		 //	get_template_part( 'template-parts/post/content', get_post_format() );
	 $id = 1267;
 $post = get_page($id);
 $content = apply_filters('the_content', $post->post_content);
 echo $content;

			/*	the_posts_pagination(
						'prev_text'          => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>',
						'next_text'          => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
						'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>',

			else :

				get_template_part( 'template-parts/post/content', 'none' );


		</main><!-- #main -->
	</div><!-- #primary -->
	<?php get_sidebar(); ?>
</div><!-- .wrap -->


keep in mind that the replace $id = 1267; 1267 is the page id.

Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in WordPress

Problem: When trying to import RSS via a built-in plugin, there is an error occurred Call to undefined function set_magic_quotes_runtime()

If you are using PHP 5.3 or after, set_magic_quotes_runtime() is already deprecated, although it will not cause a Fatal error it will send an E_DEPRECATED warning.

Solution: Remove all set_magic_quotes_runtime() in the WordPress project

material_select is not a function error in Materialize CSS

Problem: Using CDN and, there is an error on console -- material_select is not a function

It is because of material_select() method only in Materialize CSS version v0.100.2

Solution: switch materialize CSS file from 1.0.0 to 0.100.2 --

“too many connections mysql” error occurred in MariaDB, CentOS 7

Problem: Too many connections error occurred and you can’t access via PHPMyAdmin or command line.

This is because no more connection can be made, so you have to stop MySQL service and change the setting.

Solution: first stop MySQL service, I user MariaDB so the service will be mariadb:

systemctl stop mariadb
systemctl start mariadb

then enter MySQL prompt via MySQL, and enter below query to check current maximum connection:

SHOW VARIABLES LIKE "max_connections";

The default value is 151. You can set a higher one like

SET GLOBAL max_connections = 1000;

3/3/2020: And you should add a timeout parameter to close any connections that no longer used by user. Append parameter in /etc/my.cnf:

sudo vim /etc/my.cnf

Then add wait_timeout = 600 under [mysqld] to timeout any idle connection exceed 10 minutes.

Make Gmail trust your domain email using SPF in Zoho

Problem: My domain email message always being sent to the trash bin in Gmail with a notification “Why is this message in spam”. And you have to click “Report not spam” so that you can view the image.

It is because your email isn’t authenticated. Below solution using SPF to authenticate email.

Solution: First, go to the domain DNS to add below record if you are using Zoho:

then wait for about 30mins. Then go to SPF panel to validate the domains

Then your message from that email will not be spam anymore.

Close Bitnami banner