Is it possible to give the user the chance to select between two single template files to use in a post?

If the differences in the pages are just query arguments the you can add query vars and use them in the same template: //add your arguments to query vars add_filter(‘query_vars’, ‘my_query_vars’); function my_query_vars($vars) { // add my_sortand ptype to the valid list of variables you can add as many as you want $new_vars = array(‘my_sort’,’ptype’); … Read more

Manage Private Posts

You could perhaps: 1) Create the category for your Private posts, e.g. “Private” 2) Exclude the “Private” category from your main Loop 3) Output the “Private” category using a custom template file, e.g. category-private.php 4) Wrap the Loop in category-private.php in an if ( is_user_logged_in() ) conditional (This assumes, of course, that you are the … Read more

Moving the blog page

When you are selecting a static page as homepage, you can use an existing page(or a new page) to select as blog page. It won’t need any custom code to display anything. If you want to display a blog on a page which as a slug /blog/ to display the blog layout with your own … Read more

How to add the time of a post to the list of posts on the administration page?

Try this: add_filter(‘manage_posts_columns’, ‘posts_columns’, 5); add_action(‘manage_posts_custom_column’, ‘posts_custom_columns’, 5, 2); function posts_columns($defaults){ $defaults[‘your_date_col’] = __(‘Date’); return $defaults; } function posts_custom_columns($column_name, $id){ if($column_name === ‘your_date_col’){ echo the_date(); } }

Filtering posts on Post Administration Page by Week Number instead of by Month

here you go , its something i quickly cooked up and it seems to work fine: <?php /* Plugin Name: admin-filter-by-week Plugin URI: http://en.bainternet.info Description: answer to Filtering posts on Post Administration Page by Week Number instead of by Month http://wordpress.stackexchange.com/questions/19186/filtering-posts-on-post-administration-page-by-week-number-instead-of-by-month Version: 1.0 Author: Bainternet Author URI: http://en.bainternet.info */ add_filter( ‘parse_query’, ‘week_admin_posts_filter’ ); add_action( ‘restrict_manage_posts’, … Read more

Edit multiple custom post types while saving a new or edited post

here is how i would do that: add_action(‘save_post’,’update_all_meta’); function update_all_meta($post_id){ // verify if this is an auto save routine. // If it is our form has not been submitted, so we dont want to do anything if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; //check for post type if ( $post->post_type != “YOUR_CUSTOM_TYPE” ) … Read more

How to display Changing post link for 24 hours in x category

You could always use get_posts() to return a random post, but it would change every time the page loaded. So, here’s an idea for you. In a plugin file, set up a wp_cron hook. <?php /* Your plugin header goes here */ register_activation_hook( __FILE__, ‘wpse24234_activation’ ); function wpseo24234_activation() { wp_schedule_event( time(), ‘daily’, ‘wpse24234_daily’ ); } … Read more

How to create a “latest news” page showing a list of posts from blog category

Probably the get_posts tag. It’s simple, you just need a loop. <?php $args = array( ‘numberposts’ => 5, ‘cat’ => 5 ); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?> <div> <?php the_date(); ?> <br /> <?php the_title(); ?> <?php the_excerpt(); ?> </div> <?php endforeach; ?> That will show the last … Read more