• 0

Creating post filters in Wordpress with PHP


Question

Here is the design I have mocked up

http://enormo.us/clients/ischool/

The question is, how can I create a filtering system where the main blog area acts as the central feed and it combines. I would know how to do one of those rows at a time, but im having trouble with all three together.

For instance clicking on ischool life, students, and comments; would bring up only posts that are in the category iSchool Life, written by students, and sorted by the most comments.

Any help would be appreciated, even doing this type of thing not related to WordPress that would be cool too. I know it is used in eCommerce sites all the time.

Thanks,

Dave

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

You can't sort the comments like that but you can create custom post types to have those for 'iSchool.' The only way you'd be able to sort would be per-post when you're in the post edit view.

A very basic custom post type would be the following and of course added to your theme's functions.php:

add_action( 'init', 'create_ischool' );
function create_ischool() {
  $labels = array(
    'name' => _x('iSchool', 'post type general name'),
    'singular_name' => _x('iSchool', 'post type singular name'),
    'add_new' => _x('Add New', 'iSchool Post'),
    'add_new_item' => __('Add New iSchool Post'),
    'edit_item' => __('Edit iSchool Post'),
    'new_item' => __('New iSchool Post'),
    'view_item' => __('View iSchool Posts'),
    'search_items' => __('Search iSchool Posts'),
    'not_found' =>  __('No iSchool Posts found'),
    'not_found_in_trash' => __('No iSchool Posts found in Trash'),
    'parent_item_colon' => '',
    'menu_position' => 5,
    'rewrite' => array('slug'=>'ischool'),
    'supports' => array('title', 'editor', 'custom-fields', 'excerpt', 'comments'),
    'taxonomies' => array('post_tag')
  );


  register_post_type( 'ischool',
    array(
      'labels' => $labels,
      'public' => true
    )
  );
}

That would create a new menu under 'Posts' labeled 'iSchool' and you'd be able to have a custom taxonomy for just iSchool (it uses tags but you can switch to category, it's just sample code.) The post type would support title (permalink /ischool/post-name, remember to rebuild your permalinks after saving your functions.php), the post editor, custom fields and excerpt.

Reference to http://codex.wordpress.org/Post_Types for more.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.