Adding an Archive button to posts page for administrators

Here is something i have used before as a solution for changing the post category (or any term/taxonomy) just make sure you set the right $post_type,$append,$taxonomy,$terms <?php /* Plugin Name: Simple Ajax set cat Plugin URI: http://en.bainternet.info Description: dead simple lightweight plugin to add a post row action link to set a post category by … Read more

Multiple Loops Breaking Pages

Your page is behaving weirdly because you are using query_posts which clobbers the main query. Anything else on the page that depends on the main query has the wrong information after your query_posts runs. Don’t use query_posts. $qry = new WP_Query(‘category_name=News and Events, Uncategorized&showposts=5’); if ($qry->have_posts()) { while ($qry->have_posts()) { $qry->the_post(); // your Loop as … Read more

Retrieve only posts from a specific user in wp-admin/edit.php

You will need to filter that list. function alter_views_wpse_103613($views) { $role=”blogger_simple”; if (current_user_can($role)) { $views = array(‘mine’=>$views[‘mine’]); } return $views; } add_filter( ‘views_edit-post’, ‘alter_views_wpse_103613’ ); That filter list is part of the WP_List_Table class if you want to investigate more. Look for the views method.

do more action after I publish a post

There are a number of hooks you can use, such as publish_post or save_post, e.g.: // an example of a post save hook add_action( ‘save_post’, ‘diligents_post_save_hook’ ); function diligents_post_save_hook( $post_id ) { //verify post is not a revision if ( !wp_is_post_revision( $post_id ) ) { // do things } } save_post will fire on publish … Read more

post category in wp_insert_post

I did not actually test your code thoroughly, but on the first glimpse: your form input is named post_category while you’re grabbing $_POST[‘new_cat’]. Adjusting that (e.g., set both to post_category) should already do. // EDIT And why are you grabbing $_POST[‘category’] in line 5?

While loop articles – if statement order

Prepare the query before you loop over it: $first = array_shift( $the_query->posts ); $second = array_shift( $the_query->posts ); // now re-add in reverse order array_unshift( $the_query->posts, $first ); array_unshift( $the_query->posts, $second ); // this is now the first item while ($the_query -> have_posts()) : $the_query -> the_post(); // regular loop

How to get posts and comments amount per hour, per year and per month?

For comments: function count_comments_in_period( $date_from, $date_to ){ global $wpdb; $count = $wpdb->get_var( $wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_date >= %s AND comment_date < %s “, $date_from, $date_to)); return $count; } Just use dates in yyyy-mm-dd format. For posts: function count_posts_in_period( $date_from, $date_to ){ global $wpdb; $count = $wpdb->get_var( $wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_date >= … Read more

Dynamically switch template on click

My answer is something like an application of one of the @allenericr answer points + some cache. I suggest to implement this only if the 3 templates are different in the content and not only in the aspect, otherwise a CSS + JS solution should be the best choice. Create a main page template ‘multi-template-page.php’ … Read more