0

I would like to reproduce on Wordpress the same behaviour of mediawiki when it comes to display the posts of a certain category (with an alphabetical order, in columns and using first letters in bold as section titles). Do you think it's possible ?if yes, how would I do that ?

Currently I'm using a wordpress blog as a Laboratory Notebook and would like to add to it the good sides of a wiki. I already have the post revisions but this kind of category view is a plus I would like to add. It's one of the feature that makes me have difficulties to choose between both applications.

Thanks in advance for your help.

3

You can play with Walker to customize output into being split by letters. From there it is matter of CSS to achieve column formatting.

Quick take on Walker:

class Walker_Alphabetized_Category extends Walker_Category {

    var $letter = '';

    function start_el(&$output, $category, $depth, $args) {

        $current_letter = strtoupper(substr($category->name,0,1));

        if( empty($this->letter) ) {

            $this->letter = $current_letter;
            $output .= "<li>{$current_letter}<ul>";
        }
        elseif( $this->letter != $current_letter ) {

            $output .= "</ul></li>";
            $this->letter = $current_letter;
            $output .= "<li>{$current_letter}<ul>";
        }

        parent::start_el(&$output, $category, $depth, $args);
    }
}

echo '<ul>';
wp_list_categories(array(
                    'hierarchical' => false,
                    'orderby' => 'name',
                    'title_li' => '',
                    'walker' => new Walker_Alphabetized_Category(),
                   ));
echo '</ul>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.