Get all custom post types excepted some…

Following code generates the array to use as argument. <?php // Excluded CPTs. You can expand the list. $exclude_cpts = array( ‘portfolio’ ); // Builtin types needed. $builtin = array( ‘post’, ‘page’, ‘attachment’ ); // All CPTs. $cpts = get_post_types( array( ‘public’ => true, ‘_builtin’ => false ) ); // remove Excluded CPTs from All … Read more

How do I Redirect a WordPress Page?

I’m sure there is a more elegant way of achieving your desires, however this method does work. Just tested it. /** * Redirect pages from array. * * @author Michael Ecklund * @author_url https://www.michaelbrentecklund.com/ * * @return void */ function redirect_pages() { // Page from => Page to $redirect_pages = array( ‘wordpresspage’ => ‘/wordpress-page’ ); … Read more

add to end of post in the loop with plugin

It sounds like you want a filter on the_content. function add_content_wpse_97277($content) { global $post; if ($post->ID == 123) { $content .= ‘additional content’; } return $content; } add_filter(‘the_content’,’add_content_wpse_97277′); I don’t know what conditions you need though. You did not explain that in the question. The above should match a post with an ID of “123”. … Read more

How to make only posts show date

There are two options: Create a separate single.php for posts and show the date there only. Use a condition: if ( is_single() ) { ?><div class=”date”><strong><?php the_date(); ?></strong></div><?php }

Show comment number per author per day

You can try this query that counts user comments by using the user_id field in the comments table as a filter: function count_user_comments_today( $uid ){ global $wpdb; $today = date(‘Y-m-d’); $tomorrow = date(‘Y-m-d’, time() + 86400); $count = $wpdb->get_var( $wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_date >= %s AND comment_date < %s … Read more

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.