Display more than 10 posts on author.php file

when you use the loop the number of post displayed is choosen fron the option set in Settings->Reading in you backend. It affects all the standard loops, not only the author page. To change only for author page you have to use pre_get_posts hook and set the wanted number of posts using posts_per_page argument: add_action(‘pre_get_posts’,’change_numberposts_for_author’); … Read more

Custom Blog Loop on Home Page

don’t use query_posts() for secondary loops – When should you use WP_Query vs query_posts() vs get_posts()? get only top level categories using ‘category__in’ should not get posts from child categories for example: <?php $cats = get_categories(‘parent=0’); foreach ($cats as $cat) : $args = array( ‘posts_per_page’ => 1, ‘category__in’ => array( $cat->term_id ) ); $top_cat_query = … Read more

current-user_can not working in loop

From Codex : Do not pass a role name to current_user_can(), as this is not guaranteed to work correctly (see #22624) Instead, you may wish to try the check user role function put together by AppThemes. I would propose to use is_user_logged_in() to check your function.

Breaking up the results of a loop

Instance of WP_Query tracks number of current post in current_post property, zero based. So inside your loop you can check for something like if ( 2 == $subpages->current_post ) and output your additional content.

Adding first and last classes to three column layout in Bones boilerplate

I’ve just managed to resolve this now. This <?php $counter = 1; //counter tracks the number of the post we’re on ?> needed to be above <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query(‘showposts=3’ . ‘&paged=’.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> (not below). End code that works correctly is:- <?php $counter = … Read more

Print the whole page?

First of all, your page templates will normally include everything needed to make up a page, i.e. including this structure: <html> <head></head> <body></body> </html> which is not what you want over and over in your one-pager. However if you’ve built your templates using the get_template_part() function (described quite well over here) you can reuse it … Read more