Custom Blog Post Page

When you set a page to be the page for posts it no longer operates like a vanilla page, the template hierarchy dictates a different set of templates for that page. Your selected template doesn’t appear to work, because it’s not being loaded. See the template hierarchy for more info. You should name your template … Read more

how to find user ids of all commenters in a post

The get_comments() answer by Poulomi Nag is correct. This will be somewhat more efficient. global $wpdb, $post; $query = sprintf(“SELECT user_id FROM {$wpdb->comments} JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->comments}.comment_post_ID WHERE comment_post_ID = %d AND comment_approved = ‘1’”, $post->ID); $authors = $wpdb->get_col($query); $authors = array_unique($authors); $authors = array_diff($authors,array(‘0’)); // Remove those where users are not registered … Read more

Alternating post layout

minimal necessary correction – move the_post(); to before the if(($i%2 == 0) : for instance: <?php if (have_posts()) : while(have_posts()) : the_post(); $i++; if(($i % 2) == 0) : ?>

Add code just after Post content

There are some global variables available (or not) to detect the current page number: if ( empty ( $GLOBALS[‘multipage’] ) or $GLOBALS[‘numpages’] === $GLOBALS[‘page’] ) echo ‘<a id=”lastPageLink” href=”#comment”>comment</a>’; The best way to understand what they do is a look at the internals of wp_link_pages(). (bool) $GLOBALS[‘multipage’] is TRUE if there is more than one … Read more

Display most recent post in full, excerpts of older posts

This is the basic idea behind what you want. Extend/Customize to your liking. if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); // Incrementing a not instantiated variable results in 1 // so there’s no need to set it to 0 beforehand if ( 0 < $is_first_post++ ) the_excerpt(); else the_content(); endwhile; … Read more

Downgrade user from role that allows post creation

You can add actions to the set_user_role hook: add_action( ‘set_user_role’, ‘wpse98904_remove_demoted_user_posts’, 10, 2 ); function wpse98904_remove_demoted_user_posts( $demoted_author_id, $role ) { if( ‘subscriber’ == $role ) { // In here you’d search for all the posts by the user $args = array( ‘numberposts’ => -1, ‘author’ => $demoted_author_id, ‘post_type’ => ‘{your custom post type name}’, // … Read more