WordPress Plugin Blog

Self portrait, obviously

Self portrait, obviously

I have set up this blog for my tweaked WordPress plugin, ‘PostMash Filtered’, so I can take comments, feedback, bug reports, and all that kind of sh*t.

Cheers

Selwyn

Advertisements

June 19, 2009 at 7:27 pm 1 comment

Post Mash Filtered

postMash Filtered is a simple tweak of another WordPress plugin written by Joel Starnes, postMash. However, the admin panel has been modified to allow you to filter posts by Category and Date, before you reorder them. Previously, you could only reorder from a list of all the posts in your sites blog.

I have also added a function to allow you to use WordPresses inherent ‘Next Post Link’ ‘Previous Post Link’ calls, but call by the new menu order, not by date, so that when your template is reconfigured (using the instructions below) to list all posts by your new, custom order, the ‘Next Post Links’ and ‘Previous Post Links’ will match this order. Please read instructions for using this below.

Details of postMash

Posts are usually listed in reverse chronological order as they are often used for posting regular time-orientated content, however if you want to choose the order they appear in, then this is the plugin for you.
Usage

To make use of this chosen order you will need to modify your template code:
Open wp-content/themes/your-theme-name/index.php and find the beginning of ‘the loop’. Which will start:

if(have_posts())

Then add the following code directly before this:

<?php
$wp_query->set(‘orderby’, ‘menu_order’);
$wp_query->set(‘order’, ‘ASC’);
$wp_query->get_posts();
?>

This just tells WP to get the posts ordered according to their ‘menu_order’ position. Therefore you can get the posts ordered anytime you use a function such as get_posts simply by giving it the required arguments:

<?php get_posts(‘orderby=menu_order&order=ASC’); ?>

Checkout the get_posts() function in the wordpress codex for more info.
Note that it says menu_order is only useful for pages, posts have a menu_order position too, it just isn’t used. postMash provides you with an iterface so that you can use it.

Next/Previous Links

to call the next and previous links in the same order as your new post order, in your templates ‘single.php’ use the following commands, in place of the original ‘next_post_link()’ and ”previous_post_link()’ (all other variables work the same within this function);

next_post_link_menu()

previous_post_link_menu()

Admin Panel Post Order

To view posts in the same order as postMash in the regular admin panel, edit wp-admin/includes/post.php at line 794 to look like;

if ( isset($q[‘post_status’]) && ‘pending’ === $q[‘post_status’] ) {
$order = ‘ASC’;
$orderby = ‘menu_order’;
} elseif ( isset($q[‘post_status’]) && ‘draft’ === $q[‘post_status’] ) {
$order = ‘ASC’;
$orderby = ‘menu_order’;
} else {
$order = ‘ASC’;
$orderby = ‘menu_order’;
}

Download Plugin

June 19, 2009 at 7:25 pm 27 comments


My Other Blog