Articles Options here. Questions on configuration, etc.? Make sure to read the README. Version: 1.2 Author: Alex King Author URI: http://alexking.org */ load_plugin_textdomain('alexking.org'); function aka_install() { add_option('aka_columns', '1'); add_option('aka_token', '1'); } if (isset($_GET['activate']) && $_GET['activate'] == 'true') { if (get_option('aka_columns') == '') { aka_install(); } } function aka_request_handler() { if (isset($_POST['ak_action'])) { switch ($_POST['ak_action']) { case 'aka_update_settings': aka_update_settings(); break; } } } add_action('init', 'aka_request_handler'); function aka_head() { if (get_option('aka_columns') == 2) { print(' '); } } add_action('wp_head', 'aka_head'); function aka_update_settings() { if (isset($_POST['aka_columns'])) { update_option('aka_columns', intval($_POST['aka_columns'])); } if (isset($_POST['aka_token'])) { update_option('aka_token', intval($_POST['aka_token'])); } header('Location: '.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=articles.php&updated=true'); die(); } function aka_get_articles() { global $wpdb, $post; $original_post = $post; $columns = get_option('aka_columns'); $now = gmdate("Y-m-d H:i:s",time()); $posts_data = $wpdb->get_results(" SELECT $wpdb->posts.* FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_date_gmt < '$now' AND $wpdb->postmeta.meta_key = 'article' AND $wpdb->postmeta.meta_value = '1' GROUP BY $wpdb->posts.ID ORDER BY $wpdb->posts.post_date_gmt DESC "); if (!$posts_data || count($posts_data) == 0) { return ''; } $posts = array(); $post_ids = array(); foreach ($posts_data as $post) { $posts['post_'.$post->ID] = $post; $post_ids[] = $post->ID; } $cats = $wpdb->get_results(" SELECT $wpdb->term_relationships.object_id, $wpdb->terms.term_id, $wpdb->terms.name, $wpdb->terms.slug FROM $wpdb->term_relationships, $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_relationships.object_id IN (".implode(',', $post_ids).") ORDER BY $wpdb->terms.slug, $wpdb->term_relationships.object_id DESC "); $output = ''; $current = ''; $open = false; $i = 0; if ($columns == '2') { $half = 0; $next = false; $output .= '
'.__('To add post to your Articles list, simply add a custom field to the post:', 'alexking.org').'
'.__('If you have enabled the token method above, you can simply add ###articles### to any post or page and your articles list will be inserted at that place in the post/page.', 'alexking.org').'
'.__('You can always add a template tag to your theme (in a page template perhaps) to show your articles list.', 'alexking.org').'
<php aka_show_articles(); ?>