This article is published under a SIGNATURE 4.0 International (CC BY 4.0) license. Signature 4.0 International (CC BY 4.0)

Author: Su Yang

Creation time: on June 28, 2019 statistical word count: 3644 words reading time: 8 minutes to read this article links: soulteary.com/2019/06/28/…


Create a personal Wiki quickly with WordPress

Earlier this year, I wrote nearly ten blog posts on how to “build aWiki from scratch” and talked about MediaWiki, Doku, Confluence, Tiddly, MoinMoin and more, but many of the systems covered here weren’t great writing experiences.

Later, I also wrote several articles on “How to build WordPress using container Technology”. According to official data, WordPress now accounts for 34% of the applications on the Internet, and the writing experience and plug-in ecosystem are actually great. So why not use WordPress to build wikis?

After using it for 4 months, I decided to share the method in the hope that it could help more people. If you are familiar with WordPress setup, this article should be ready in two or three minutes.

Clear goals

Before setting up, let’s clarify the main functions of a personal Wiki (in my case) :

  • Easy to use editor, Markdown support.
  • Support full-text search, can quickly obtain reference content according to keywords.
  • Support attachment management, preferably can support remote picture automatic transfer.
  • Supports classification and labeling.
  • Optional support for comments (omitted for single use).
  • High scalability, but as low maintenance as possible.

Although these features are “basic”, the software mentioned at the beginning of this article more or less does not support these features, or does not do well.

Lead to

The construction process was mentioned in the previous article, and interested students can browse through it.

  • WordPress with Docker and Traefik
  • Build WordPress with Docker and Traefik

Of course, you can also build with traditional solutions.

Wiki Interface customization

With the latest version 5.0 of the software installed by default, you will see the following screen.

The default interface is suitable for displaying blog list content, which is not particularly Wiki friendly. The solution is simple: go to admin and change the theme of ** 2019 to ** Twenty Sixteen**.

Then click the “Customize” button above the theme to start customizing the theme. Click the small tool in the left menu, and then adjust the theme according to your needs. For example, HERE I have retained four modules of “search box”, “classification catalogue”, “recent articles” and “features”, and adjusted the modules in this order.

Then open the Read page in the Settings menu, adjust the home page display to a static page, and select the static page as the sample page.

The page currently displayed still doesn’t look like a Wiki, so let’s move on.

Again, open the Theme menu page in the admin background and select the last item (Theme Editor) to start modifying the Theme source file. (if for some reason you cannot directly modify this file, the browser can also through the wp editor – the content/themes/twentysixteen/page. The PHP files to achieve the same effect)

Select page.php on the right, and the original code looks like this:

<? php /** * The templatefor displaying pages
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages and that
 * other "pages"on your WordPress site will use a different template. * * @package WordPress * @subpackage Twenty_Sixteen * @since Twenty Sixteen 1.0 */ get_header(); ? > <div id="primary" class="content-area">
	<main id="main" class="site-main" role="main"> <? php // Start the loop.while ( have_posts() ) :
			the_post();

			// Include the page content template.
			get_template_part( 'template-parts/content'.'page' );

			// If comments are open or we have at least one comment, load up the comment template.
			if( comments_open() || get_comments_number() ) { comments_template(); } // End of the loop. endwhile; ? > </main><! -- .site-main --> <? php get_sidebar('content-bottom'); ? > </div><! -- .content-area --> <? php get_sidebar(); ? > <? php get_footer(); ? >Copy the code

Modify very simple, we put the bottom get_sidebar(); Place it before


and add a style.

<? php /** * The templatefor displaying pages
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages and that
 * other "pages"on your WordPress site will use a different template. * * @package WordPress * @subpackage Twenty_Sixteen * @since Twenty Sixteen 1.0 */ get_header(); ? > <div id="primary" class="content-area"> <style> .sidebar{ column-count: 5; column-width: 240px; column-gap: 20px; } </style> <? php get_sidebar(); ? > <main id="main" class="site-main" role="main"> <? php // Start the loop.while ( have_posts() ) :
			the_post();

			// Include the page content template.
			get_template_part( 'template-parts/content'.'page' );

			// If comments are open or we have at least one comment, load up the comment template.
			if( comments_open() || get_comments_number() ) { comments_template(); } // End of the loop. endwhile; ? > </main><! -- .site-main --> <? php get_sidebar('content-bottom'); ? > </div><! -- .content-area --> <? php get_footer(); ? >Copy the code

When you populate a Wiki properly, you get pages like this.

Markdown syntax support

Search and install WP Githuber MD in the Plugin center, and when you’re done, make sure to enable the plugin.

When you open the editor again, the wySIWYG editor becomes the familiar Markdown editor with left and right columns.

Code highlighting

As browsers become more and more powerful, there is almost no need to use server-side code highlighting anymore. And personal wikis have little need for search engine SEO.

Search for and install WP Code highlight.js in the plugin center. When the plugin is enabled, the Code in the article will be automatically highlighted.

Automatic User login

If you are a personal user, set up on the Intranet, and do not need to consider permissions, then you can set up WordPress automatic login like I did.

In wp-config.php require_once ABSPATH. ‘wp-settings.php’; Before, add the following code.

if ($_SERVER['SCRIPT_NAME'] = ='/wp-login.php') {

    require_once ABSPATH . 'wp-settings.php';
    require_once ABSPATH . '/wp-load.php';

    if (
        isset($_SERVER['QUERY_STRING']) &&
        (strpos($_SERVER['QUERY_STRING'].'=logout')! = =false)
    ) {
        wp_destroy_current_session();
        wp_clear_auth_cookie();
        do_action('wp_logout');
    } else {
        $user_login = getenv('WP_USER');

        $user = get_userdatabylogin($user_login);
        $user_id = $user->ID;

        wp_set_current_user($user_id.$user_login);
        wp_set_auth_cookie($user_id);
        do_action('wp_login'.$user_login);
    }
    wp_redirect(home_url(), 302);

    die;
}
Copy the code

The implementation principle is very simple, before the implementation of the program, hijacking the application login route, automatically set the login status for the user.

The last

WordPress is an open source and free software written in PHP. As mentioned earlier, according to official data, it now accounts for 34% of Internet software.

Use the software that powers over 34% of the web. — wordpress.org/download

I personally have been using it since 2009:

When I was working in Sina Cloud, I was responsible for the development and maintenance of WP4SAE. Even without looking at the data downloaded from the platform, I could find that many colleagues used it every time I changed companies, which showed that the number of users should be quite good (chuckling). When I was working at Taobao, I wrote several WP plug-ins with good downloads, one of which was officially recommended by 360 CDN resource website (used to replace Google Fonts and speed up blog opening). Also based on it (Taobao UED blog) made a set of automated D2 meeting electronic ticket program, the history of GitHub warehouse up to now there are nearly thousands of pull requests and hundreds of fork; I also used it internally as a replacement for Confluence to store a number of modified technical articles…

In a way, I’ve seen the software evolve. Of course, I benefited from this software many times during my personal growth. I think it’s a great piece of software and, in a sense, a very successful open source project.

But judging by online postings, there is often excessive criticism when it comes to the app, with many people unaware that things have changed. There was even a criticism that WordPress was politically correct… There is no silver bullet in technology, nor is software. It is what technical people should do to use the right technology in the right scene and analyze and solve problems, rather than just criticize and ridicule.

Thanks to WordPress, I’ve saved a lot of time doing more interesting things.

– EOF


I now have a small toss group, which gathered some like to toss small partners.

In the case of no advertisement, we will talk about software, HomeLab and some programming problems together, and also share some technical salon information in the group from time to time.

Like to toss small partners welcome to scan code to add friends. (Please specify source and purpose, otherwise it will not be approved)

All this stuff about getting into groups