List Wiki Categories on the homepage like how the template lists posts.

Hi, Thank you for an awesome plugin :slight_smile:
I am using the know how theme http://demo.herothemes.com/knowhow/ to make a wiki using the wiki plugin. I would like to display the wiki categories(with wiki count) and wiki titles that link to the wiki.
I did approach the theme maker but he has declined to assist as they do not support 3rd party plugins.
I hope you can help. My skills. I can manage the css, and copy paste php/html where required. :slight_smile:
Look forward to hearing from you.
Let me know if you want the url to the install.

  • Rajesh

    Hi Jack,
    Thank you for your reply. I understand you do not take up custom development.
    What i am looking to do is create a page that displays the output of the wiki.
    for example:

    Category Name (21)- post count in the bracket
    - Sub category Name(4)
    -- Wiki Title

    If i can get the hooks to display the above then ill see if i can create a page template with it. I took a look at inscub_wiki.php. Didnt help!
    Cheers

  • Hoang Ngo

    Hi @Rajesh,

    I hope you are well today and thanks for your clarification.

    I will need more information to have a closer look for this issue, can you please send in:

    - Mark to my attention - ATTN: Hoang Ngo
    - Link back to this thread
    - Include admin/network access
    - Include FTP
    - Include any relevant URLS for your site

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    Best Regards,
    Hoang

  • Saurabh

    Hi @Rajesh,

    Thank you for your patience.

    To show your complete wiki on your home page, you can do one of these two things:

    1. Edit the home.php file of the theme and replace it with the code below. This is simple and fast. However, these changes will be lost if the theme is updated.
    2. Create a child theme using this tutorial: https://premium.wpmudev.org/blog/how-to-create-a-wordpress-child-theme-in-3-steps/

    After step 2, create a new file called home.php and paste the following code to it:

    <?php get_header(); ?>
    
    <?php
    // Get HP sidebar position
    $st_hp_sidebar = of_get_option('st_hp_sidebar');
    if ($st_hp_sidebar == 'fullwidth') {
        $st_hp_sidebar = 'sidebar-off';
    } elseif ($st_hp_sidebar == 'sidebar-l') {
        $st_hp_sidebar = 'sidebar-left';
    } elseif ($st_hp_sidebar == 'sidebar-r') {
        $st_hp_sidebar = 'sidebar-right';
    } else {
        $st_hp_sidebar = 'sidebar-right';
    }
    ?>
    
    <!-- #primary -->
    <div id=&quot;primary&quot; class=&quot;<?php echo $st_hp_sidebar; ?> clearfix&quot;>
        <!-- .container -->
        <div class=&quot;container&quot;>
    
            <!-- #content -->
            <section id=&quot;content&quot; role=&quot;main&quot;>
    
                <header id=&quot;page-header&quot;>
                    <h2 class=&quot;page-title&quot;>
                        <?php _e('Article Categories', 'framework') ?>
                    </h2>
                </header>
                <div id=&quot;homepage-categories&quot; class=&quot;clearfix&quot;>
                    <?php
    // Get homepage options
    // Set category counter
                    $st_cat_counter = 0;
    
    // Base Category Query
                    $st_hp_cat_args = array(
                        'orderby' => 'name',
                        'order' => 'ASC',
                        'hierarchical' => true,
                        'hide_empty' => 0,
                        'taxonomy' => 'incsub_wiki_category',
                        'pad_counts' => 1
                    );
    
                    $st_categories = get_categories($st_hp_cat_args);
                    $st_categories = wp_list_filter($st_categories, array('parent' => 0));
    // If there are catgegories
                    if ($st_categories) {
                        foreach ($st_categories as $st_category) {
                            $st_cat_counter++;
    
                            if ((!is_int($st_cat_counter / 2)) && $st_cat_counter != 1) {
                                echo '</div><div class=&quot;row&quot;>';
                            } elseif ($st_cat_counter == 1) {
                                echo '<div class=&quot;row&quot;>';
                            }
    
                            echo '<div class=&quot;column col-half ' . $st_cat_counter . '&quot;>';
                            echo '<h3> <a href=&quot;' . get_category_link($st_category->term_id) . '&quot; title=&quot;' . sprintf(__('View all posts in %s', 'framework'), $st_category->name) . '&quot; ' . '>' . $st_category->name . '</a>';
                            if (of_get_option('st_hp_cat_counts') == '1') {
                                echo '<span class=&quot;cat-count&quot;>(' . $st_category->count . ')</span>';
                            }
                            echo '</h3>';
    
    // Sub category
                            $st_sub_category = get_category($st_category);
                            $st_subcat_args = array(
                                'orderby' => 'name',
                                'order' => 'ASC',
                                'child_of' => $st_sub_category->cat_ID,
                                'pad_counts' => 1,
                                'taxonomy' => 'incsub_wiki_category',
                            );
                            $st_sub_categories = get_categories($st_subcat_args);
                            $st_sub_categories = wp_list_filter($st_sub_categories, array('parent' => $st_sub_category->cat_ID));
    
    // If there are sub categories show them
                            if ($st_sub_categories && (of_get_option('st_hp_subcat') == 1)) {
                                foreach ($st_sub_categories as $st_sub_category) {
                                    ?>
                                    <ul class=&quot;sub-categories&quot;>
                                        <li>
                                            <h4><?php
                                                echo '<a href=&quot;' . get_category_link($st_sub_category->term_id) . '&quot; title=&quot;' . sprintf(__('View all posts in %s', 'framework'), $st_sub_category->name) . '&quot; ' . '>' . $st_sub_category->name . '</a>';
                                                if (of_get_option('st_hp_subcat_counts') == '1') {
                                                    echo '<span class=&quot;cat-count&quot;>(' . $st_sub_category->count . ')</span>';
                                                }
                                                ?></h4>
                                        </li>
                                    </ul>
                                <?php
                                }
                            }
    
                            global $post;
    
    // If show posts is 0 do nothing
    
                            $st_cat_post_args = array(
                                'post_type' => 'incsub_wiki',
                                'tax_query' => array(
                                    array(
                                        'taxonomy' => 'incsub_wiki_category',
                                        'field' => 'id',
                                        'terms' => $st_category->term_id
                                    )
                                )
                            );
    
                            $st_cat_posts = get_posts($st_cat_post_args);
                            echo '<ul class=&quot;category-posts&quot;>';
                            foreach ($st_cat_posts as $post) : setup_postdata($post);
                                ?>
                                <?php
                                // Set post format class
                                if (has_post_format('video')) {
                                    $st_postformat_class = 'video';
                                } else {
                                    $st_postformat_class = 'standard';
                                }
                                ?>
                                <li class=&quot;format-<?php echo $st_postformat_class; ?>&quot;><a href=&quot;<?php the_permalink(); ?>&quot;>
                                <?php the_title(); ?>
                                    </a></li>
    
                                <?php
                            endforeach;
    
                            echo '</ul>';
    
                            echo '</div>';
                        }
                    }
                    ?>
                </div>
        </div>
    
    </section>
    <!-- #content -->
    
    <?php if (of_get_option('st_hp_sidebar') != 'fullwidth') { ?>
        <?php get_sidebar(); ?>
    <?php } ?>
    
    </div>
    <!-- /.container -->
    </div>
    <!-- #primary -->
    
    <?php get_footer(); ?>

    I did test it on your site and it works nicely. I have attached a screenshot.

    Best

    Saurabh

  • Rajesh

    @Saurabh Shukla
    WOW !!! You are mighty :slight_smile:
    I have added it in the child theme as uou suggested and have it working.
    That was brilliant Saurabh,
    Just Two more things,
    1-the Category and sub-category (Class 01 and English) show up as hyperlink but they do not link there. Like a dummy.
    Any idea what i need to do to enable them to be actual links?
    and then i think im sorted :smiley:

    2- On the wiki page where the breadcrumb does not show the subcategory or parent category of the wiki. In the wiki settings for the number of titles to add to bread crubs i have mentioned 8. and my permalinks is set to /%category%/%postname%/

    Any idea how to fix it.
    Once again Thank you so much.

  • Saurabh

    Hi Rajesh,

    1-the Category and sub-category (Class 01 and English) show up as hyperlink but they do not link there.

    In the process of not changing the code much beyond the original theme's, I missed changing get_category_link function in the code above to get_term_link. I have made that change. The code is posted at the end for reference.

    2- On the wiki page where the breadcrumb does not show the subcategory or parent category of the wiki. In the wiki settings for the number of titles to add to bread crubs i have mentioned 8. and my permalinks is set to /%category%/%postname%/

    This is a tad difficult, because wiki posts are heirarchial (like pages). So even though they can be organised into categories and tagged like posts, their permalinks won't contain those. The setting will work, if you organise your wiki as pages and child-pages. In such a case, it'll show upto 8 levels of parents in the breadcrumbs.

    I hope that clarifies this issue.

    Her's the modified code, for the theme:

    <?php get_header(); ?>
    
    <?php
    // Get HP sidebar position
    $st_hp_sidebar = of_get_option('st_hp_sidebar');
    if ($st_hp_sidebar == 'fullwidth') {
        $st_hp_sidebar = 'sidebar-off';
    } elseif ($st_hp_sidebar == 'sidebar-l') {
        $st_hp_sidebar = 'sidebar-left';
    } elseif ($st_hp_sidebar == 'sidebar-r') {
        $st_hp_sidebar = 'sidebar-right';
    } else {
        $st_hp_sidebar = 'sidebar-right';
    }
    ?>
    
    <!-- #primary -->
    <div id=&quot;primary&quot; class=&quot;<?php echo $st_hp_sidebar; ?> clearfix&quot;>
        <!-- .container -->
        <div class=&quot;container&quot;>
    
            <!-- #content -->
            <section id=&quot;content&quot; role=&quot;main&quot;>
    
                <header id=&quot;page-header&quot;>
                    <h2 class=&quot;page-title&quot;>
                        <?php _e('Article Categories', 'framework') ?>
                    </h2>
                </header>
                <div id=&quot;homepage-categories&quot; class=&quot;clearfix&quot;>
                    <?php
    // Get homepage options
    // Set category counter
                    $st_cat_counter = 0;
    
    // Base Category Query
                    $st_hp_cat_args = array(
                        'orderby' => 'name',
                        'order' => 'ASC',
                        'hierarchical' => true,
                        'hide_empty' => 0,
                        'taxonomy' => 'incsub_wiki_category',
                        'pad_counts' => 1
                    );
    
                    $st_categories = get_categories($st_hp_cat_args);
                    $st_categories = wp_list_filter($st_categories, array('parent' => 0));
    // If there are catgegories
                    if ($st_categories) {
                        foreach ($st_categories as $st_category) {
                            $st_cat_counter++;
    
                            if ((!is_int($st_cat_counter / 2)) && $st_cat_counter != 1) {
                                echo '</div><div class=&quot;row&quot;>';
                            } elseif ($st_cat_counter == 1) {
                                echo '<div class=&quot;row&quot;>';
                            }
    
                            echo '<div class=&quot;column col-half ' . $st_cat_counter . '&quot;>';
                            echo '<h3> <a href=&quot;' . get_term_link($st_category) . '&quot; title=&quot;' . sprintf(__('View all posts in %s', 'framework'), $st_category->name) . '&quot; ' . '>' . $st_category->name . '</a>';
                            if (of_get_option('st_hp_cat_counts') == '1') {
                                echo '<span class=&quot;cat-count&quot;>(' . $st_category->count . ')</span>';
                            }
                            echo '</h3>';
    
    // Sub category
                            $st_sub_category = get_category($st_category);
                            $st_subcat_args = array(
                                'orderby' => 'name',
                                'order' => 'ASC',
                                'child_of' => $st_sub_category->cat_ID,
                                'pad_counts' => 1,
                                'taxonomy' => 'incsub_wiki_category',
                            );
                            $st_sub_categories = get_categories($st_subcat_args);
                            $st_sub_categories = wp_list_filter($st_sub_categories, array('parent' => $st_sub_category->cat_ID));
    
    // If there are sub categories show them
                            if ($st_sub_categories && (of_get_option('st_hp_subcat') == 1)) {
                                foreach ($st_sub_categories as $st_sub_category) {
                                    ?>
                                    <ul class=&quot;sub-categories&quot;>
                                        <li>
                                            <h4><?php
                                                echo '<a href=&quot;' . get_term_link($st_sub_category) . '&quot; title=&quot;' . sprintf(__('View all posts in %s', 'framework'), $st_sub_category->name) . '&quot; ' . '>' . $st_sub_category->name . '</a>';
                                                if (of_get_option('st_hp_subcat_counts') == '1') {
                                                    echo '<span class=&quot;cat-count&quot;>(' . $st_sub_category->count . ')</span>';
                                                }
                                                ?></h4>
                                        </li>
                                    </ul>
                                <?php
                                }
                            }
    
                            global $post;
    
    // If show posts is 0 do nothing
    
                            $st_cat_post_args = array(
                                'post_type' => 'incsub_wiki',
                                'tax_query' => array(
                                    array(
                                        'taxonomy' => 'incsub_wiki_category',
                                        'field' => 'id',
                                        'terms' => $st_category->term_id
                                    )
                                )
                            );
    
                            $st_cat_posts = get_posts($st_cat_post_args);
                            echo '<ul class=&quot;category-posts&quot;>';
                            foreach ($st_cat_posts as $post) : setup_postdata($post);
                                ?>
                                <?php
                                // Set post format class
                                if (has_post_format('video')) {
                                    $st_postformat_class = 'video';
                                } else {
                                    $st_postformat_class = 'standard';
                                }
                                ?>
                                <li class=&quot;format-<?php echo $st_postformat_class; ?>&quot;><a href=&quot;<?php the_permalink(); ?>&quot;>
                                <?php the_title(); ?>
                                    </a></li>
    
                                <?php
                            endforeach;
    
                            echo '</ul>';
    
                            echo '</div>';
                        }
                    }
                    ?>
                </div>
        </div>
    
    </section>
    <!-- #content -->
    
    <?php if (of_get_option('st_hp_sidebar') != 'fullwidth') { ?>
        <?php get_sidebar(); ?>
    <?php } ?>
    
    </div>
    <!-- /.container -->
    </div>
    <!-- #primary -->
    
    <?php get_footer(); ?>

    Best

    Saurabh

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.