Change the Order of the Post List in Kalin’s PDF Creation Station

-- Download Change the Order of the Post List in Kalin's PDF Creation Station as PDF --

A couple people have asked for the ability to change how the posts are ordered on the Tool page of my PDF Creation Station WordPress plugin so they don’t have to spend so long reordering them before creating. I ultimately would like to create an Ajax script to refresh the list from an ‘order by’ dropdown box. That’s a little complex and time-consuming so I think there are more important things for me to be doing, so in the meantime, for version 3.0, I’ve added a way for anyone with a little PHP experience to change how the posts are ordered. If you look into kalins_pdf_tool_page.php, currently on line 16 you will see this code:

	$customList = get_posts('numberposts=-1&post_type=any&orderby=' .KALINS_PDF_POST_ORDER_BY ."&order=" .KALINS_PDF_POST_ORDER);
	$postList = get_posts('numberposts=-1&orderby=' .KALINS_PDF_POST_ORDER_BY ."&order=" .KALINS_PDF_POST_ORDER);
	$customList = get_posts('numberposts=-1&post_type=any');
	$postList = get_posts('numberposts=-1');

You can see that the code is referring to two constants called KALINS_PDF_POST_ORDER_BY and KALINS_PDF_POST_ORDER. All you need to do is define both these constants in your wp-config.php file. Doing this will keep the setting constant even after upgrading to new versions of the plugin.

define("KALINS_PDF_POST_ORDER_BY", "order type");

You may replace “ASC” with “DESC” to reverse the order. Replace order type with any of these possible values:

  • 'author' – Sort by the numeric author IDs.
  • 'category' – Sort by the numeric category IDs.
  • 'content' – Sort by content.
  • 'date' – Sort by creation date.
  • 'ID' – Sort by numeric post ID.
  • 'menu_order' – Sort by the menu order. Only useful with pages and attachments.
  • 'mime_type' – Sort by MIME type. Only useful with attachments.
  • 'modified' – Sort by last modified date.
  • 'name' – Sort by stub.
  • 'parent' – Sort by parent ID.
  • 'password' – Sort by password.
  • 'rand' – Randomly sort results.
  • 'status' – Sort by status.
  • 'title' – Sort by title.
  • 'type' – Sort by type.

3 thoughts on “Change the Order of the Post List in Kalin’s PDF Creation Station”

  1. Hi Kalin. I tried to do this but I don’t see the post changing one bit. I even tried changing asc to desc. Any tips? I’m using wordpress 3.9.1

  2. Hi there

    Great plugin! Really well done.

    Is it possible to have the list of posts on the tools.php page to be a drop down list instead of check boxes?

    Many thanks

    1. No not without changing the php. Why would you want such a feature? It would prevent you from selecting more than one post, thus defeating the whole purpose of the tools page.

Leave a Reply

Your email address will not be published. Required fields are marked *