Articles of paged

Custom posts per page does not work with pagination

I have one page in my template where I would like to set a custom posts_per_page. Here is the code I have used: <?php global $query_string; query_posts($query_string . ‘&posts_per_page=4’); if ( have_posts() ) : while ( have_posts() ) : the_post(); … Now this code limits only 4 items per page and shows pageinate_links below as […]

Does it make sense to assign functions like is_paged() to a variable rather than using it multiple times?

Actually a simple question, but I need to be sure that assigning a variable for the result of a function can help to increase the speed of a site e.g. The function: if is_paged(){ $paged = 1; } The replacement: if $paged == “1” .. then do – RATHER THAN USING THE SAME FUNCTION over […]

$wp_query->current_post restarts from zero on paged pages

I know how to keep track on the ‘index’ of the current post when running the loop using $wp_query->current_post Bu this restarts the count from zero on subsequent paged pages. So if I have 20 posts, and show 5 posts per page, then on page 2 the posts are again numbered 0-4 instead of 5-9. […]

Last comment page first with full number of comments?

I use paged and threaded comments with: 10 comments per page the last comment page first the newest comments first If there are 21 comments total, the first page only contain 1 comment – the newest. How do i get the newest 10 comments always showing on the first page? I’m using WordPress 3.0.3. Edit: […]

Customising rewrite rules for CPT single post URL to work as paged URL

I’ve got a CPT called Service registered as following: $args = array( ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘has_archive’ => false, ‘rewrite’ => array(‘slug’ => ‘services’, ‘with_front’ => false), ‘query_var’ => true, ‘capability_type’ => ‘post’, ‘hierarchical’ => false, ‘show_in_nav_menus’ => false, ‘menu_position’ => 20, ‘supports’ => array( ‘title’ ‘editor’, ‘thumbnail’, ‘author’, ‘revisions’ […]

What is the difference between $paged and $page?

I’m creating pagination for my site. Hope everyone can explain to me what below code used for? Thanks in advance. <?php if ( get_query_var(‘paged’) ) { $paged = get_query_var(‘paged’); } elseif ( get_query_var(‘page’) ) { $paged = get_query_var(‘page’); } else { $paged = 1; } query_posts(‘paged=’.$paged.’&posts_per_page=’); ?>

Customized first post techniques

There doesn’t seem to be a standard technique for differentiating first/top posts. After looking around, I found this method: $current_query = new WP_Query(‘post_type=current&post_status=publish’); // Pull out top/first post $first_post = ( $paged == 0 ) ? $posts[0]->ID : ”; while ($current_query->have_posts()) : $current_query->the_post(); if ($first_post == $post->ID) { echo ‘<div class=”post top-post-special” id=”post-‘ . get_the_ID() […]

How can I display 7 posts on the home page, but 9 posts on the subsequent pages?

The home page of my site is set to show the 9 latest posts (via the setting in the admin area), and then at the bottom I have the standard pagination links which allow visitors to view more posts. I would like to have the home page (and only the home page) show 7 latest […]

Get the number of posts from the current page results

I am trying to get the current number of posts that will be present in a page. $wp_query->found_posts will give me the total number of posts in the loop. get_query_var( ‘posts_per_page’ ) will tell me the number of posts per page. get_query_var( ‘paged’ ) will give me the current page number. sticky posts seem to […]

Change page /2 to /transcript with a Rewrite

I set up this rule (in functions.php) function custom_rewrite_basic() { add_rewrite_rule( ‘episode/([^/]+)/transcript’, ‘index.php?post_type=episodes&episodes=$matches[1]&page=2’, ‘top’); } add_action(‘init’, ‘custom_rewrite_basic’); expecting it to redirect www.domain.com/episode/postname/2/ over to www.domain.com/episode/postname/transcript/ but it’s still going to /2/. Interestingly enough, if I type in www.domain.com/episode/postname/transcript/ it still works, but does a redirect to /2/. I have installed the Rewrite Analyzer plugin and […]