How to Create a Wiki Knowledge Base Using WordPress

Are you looking to add a support / documentation section to your site? Want to know the best way to add a wiki knowledge base to your WordPress site? In this article, we will show you how to create a wiki knowledge base in WordPress.
Business Learning and Support
There are three different ways you can build a wiki site within WordPress:
  • You can use a dedicated WordPress wiki theme to build your knowledge base.
  • You can use a dedicated WordPress wiki plugin to build your knowledge base.
  • You can use some custom code snippets to build your knowledge base.
Now there are pros and cons to each method. But don’t worry, we will explain each of them, so you can make the right choice.

WordPress Wiki & Knowledge Base Theme Method

KnowHow - WordPress Knowledge Base Theme
One of the easiest way to build a wiki is to use a WordPress wiki knowledge base theme. There are tons of them available, but we recommend KnowHow Theme.
The best way to setup is to install WordPress on a subdomain or directory like support.yoursite.com or yoursite.com/knowledgebase/
Once done, you just need to install and activate the KnowHow theme and it will work out of the box.
KnowHow Preview
The biggest downside of using any WordPress Wiki & Knowledge Base theme is that you cannot use them on your main site. You have to do the setup on a subdomain or directory because these themes do not really match your branding, and you definitely do not want your homepage to be a wiki.
However many sites have their knowledge base on a subdomain, so this is not as bad as it sounds. The decision really comes down to your preference.

WordPress Wiki & Knowledge Base Plugin Method

Knowledge Base Plugin
If you want to add a wiki knowledge base to your existing WordPress site, then the easiest way to do it is by using a WordPress wiki knowledge base plugin. There are several plugins available, but we recommend Knowledge Base by PressApps (Live Demo available).
All you have to do is install and activate the plugin. Once activated, it adds a Knowledge Base tab in your WordPress admin area.
Knowledge Base Admin
Knowledge Base is it’s own custom post type with categories and tags which allows you to organize your documentation.
The best part about this is that you can add it on your main site, and it will match your brand style / formatting for the most part. It also comes with public / member only voting system, custom widgets, drag-drop functionality, etc. The downside is that it costs $20.
In our next method, we will show you how you can accomplish all of this for free, but it does involve code.

WordPress Wiki & Knowledge Base Code Snippet Method

Another way to add a wiki knowledge base to your existing WordPress site or even create a dedicated wiki site is to use the code snippet method.
The downside is that you have to copy/paste a little bit of code which can be scary for beginners. The upside is that it gives you more freedom, and it’s completely free unlike the first two options.
We will do our best to give step by step instructions.
Note: Before you start, please create a complete backup of your WordPress site.
First thing you need to do is install and activate the Knowledgebase CPT plugin. This simple plugin creates a custom post type called knowledge_base and a taxonomycalled section.
This allows you to easily add your wiki articles and organize them into sections.
Adding knowledge base articles and sections
Once you have a few articles and sections, you would need to display them on your website. This is where you need to deal with a little bit of code.
Start by adding this code snippet into your theme’s functions.php file or a site-specific plugin.
01function wpb_knowledgebase() {
02    // Get Knowledge Base Sections
03    $kb_sections = get_terms('section','orderby=name&hide_empty=0');
04    // For each knowledge base section
05    foreach ($kb_sections as $section) :
06    $return .= '<div class="kb_section">';
07    // Display Section Name
08    $return .= '<h4 class="kb-section-name"><a href="'. get_term_link( $section ) .'" title="'$section->name .'" >'.$section->name .'</a></h4><ul class="kb-articles-list">';
09     
10    // Fetch posts in the section
11    $kb_args array(
12        'post_type' => 'knowledge_base',
13        'posts_per_page'=>-1,
14        'tax_query' => array(
15            array(
16                'taxonomy' => 'section',
17                'terms'    => $section,
18            )       ,
19        ),
20    );
21     
22    $the_query new WP_Query( $kb_args );
23        if $the_query->have_posts() ) :
24            while $the_query->have_posts() ) : $the_query->the_post();
25                $return .=  '<li class="kb-article-name">';
26                $return .=  '<a href="'. get_permalink($the_post->ID ) .'" rel="bookmark" title="'. get_the_title($the_post->ID ) .'">'. get_the_title( $the_post->ID ) .'</a>';
27                $return .=  '</li>';
28            endwhile;
29    wp_reset_postdata();
30         else :
31                $return .= '<p>No Articles Found</p>';
32        endif;
33    $return .=  '</ul></div>';
34    endforeach;
35    return $return;
36}
37// Create shortcode
38add_shortcode('knowledgebase''wpb_knowledgebase');
This code lists all the knowledge base articles under the section they were filed in.
Next all you need to do is create a new WordPress page and add [knowledgebase]shortcode inside it. Save your page and preview it.
Plain knowledge base section with no CSS
It looks very plain right now, but we can add some styling to it. You can use this CSSas starting point and then continue editing to match your own colors.
Paste the following code in your theme’s style.css file.
01.kb_section {
02floatleft;
03width280px;
04max-width280px;
05margin10px;
06background-color#f5f5f5;
07border1px solid #eee;
08}
09h4.kb-section-name {
10background-color#eee;
11margin0;
12padding5px;
13}
14ul.kb-section-list {
15list-style-typenone;
16list-stylenone;
17displayinline;
18}  
19li.kb-section-name {
20list-style-typenone;
21displayinline;
22}
23ul.kb-article-list {
24list-style-typenone;
25list-stylenone;
26}  
27li.kb-article-name {
28list-style-typenone;
29}
30div.kb_section:nth-of-type(3n+1) {clear:left;}
31div.kb_section:nth-of-type(3n+3) {}
This how it looked on our demo site where we are using Twenty Twelve theme.
Styled knowledge base page in WordPress
By default, your sections will be displayed in alphabetical order. However if you want to change the order of sections, then you can do that by installing Custom Taxonomy Order NE plugin. This will allow you to drag-drop your sections in the right order.
That’s all, we hope this article helped you add a Wiki knowledge base section on your WordPress site. You may also want to check out our tutorial on how to add aFAQs section in WordPress.

--------------