Category: Process Documentation

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/passive_income/wp-content/themes/twentyseventeen/index.php, follow below content

<?php
/**
 * 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 https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @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>
		</header>
	<?php else : ?>
	<header class="page-header">
		<h2 class="page-title"><?php _e( 'Posts', 'twentyseventeen' ); ?></h2>
	</header>
	<?php endif; ?>

	<div id="primary" class="content-area">
		<main id="main" class="site-main" role="main">
   
			<?php
			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;
//https://www.passiveincomehk.com/wp-admin/post.php?post=1267
				//endwhile;

			/*	the_posts_pagination(
					array(
						'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' );

			endif;
			?>

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

<?php
get_footer();

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 https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css and https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js, 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 -- https://cdn.bootcss.com/materialize/0.100.2/css/materialize.min.css

“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;

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.

Failed to remote connect to MySQL because of many connection errors;unblock witj ‘mysqladmin flush-hosts’

Problem: My window 10 want to remote connect to Linux MySQL server, but popup with the following error:

This is because the command uses host cache tables to exceed the maximum number of connections for a particular host, MySQL server will not able to make new connections.

Solution: enter Linux server command prompt, enter below command:

mysqladmin flush-hosts

or enter MySQL command prompt, enter below query:

FLUSH HOSTS;

Enable remote MySQL/MariaDB connection

Problem: Want an outside notebook/website able to remote connect AWS server’s database.

Solution: First allow all IP to access 3306 in the security group on the AWS portal.

then change my.cnf file, add bind-address:

[mysqld]
    ...
    skip-networking
    ...
    bind-address = <some ip-address>
    ...

the ip address should be 127.0.0.1 or localhost

At last, go to the mysql command-line client by entering mysql, and enter below command to grant access for outside IP address

GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD' with grant option;

so that specific user from specific IP can remote connect to this database.