Custom Page Template and Category Exclusion

Try this code in your template. <?php /** * Template Name: Exclude Comic Category */ get_header(); ?> <div id=”primary”> <div id=”content” role=”main”> <?php query_posts( array( ‘category_name’ => ‘comic’, ‘paged’ => get_query_var(‘paged’), ‘posts_per_page’ => 5 ) ); ?> <?php if ( have_posts() ) : ?> <?php twentyeleven_content_nav( ‘nav-above’ ); ?> <?php while ( have_posts() ) : … Read more

Gallery Pagination by Row

It is definitely possible!! Ok, here is what I did… My new loop looks like: <?php $ids = array();?> <?php foreach(query_posts(“category_name=photos&showposts=-1”) as $post_blog): ?> <?php $url = wp_get_attachment_image_src( get_post_thumbnail_id($post_blog->ID), ‘gallery-full’ ); ?> <?php $thumbs = wp_get_attachment_image_src( get_post_thumbnail_id($post_blog->ID), ‘gallery-thumbnail’ ); ?> <?php list($width) = getimagesize($thumbs[0]); ?> <?php $ids[] = array(“id_post” => $post_blog->ID, “width” => $width, ‘url’ … Read more

posts_nav_link() not working on index.php

You are missing the paged= paramter. $myquery = new wp_query(‘cat=-41&paged=’ . get_query_var( ‘page’ )); Codex Note – You should set get_query_var( ‘page’ ) if you want your query to work with pagination. Tip – If you want to eclude a category from main page you can use the pre_get_post filter. That is better way to … Read more

paged query leads to 404? [duplicate]

A couple of points you should try out: Remove the ‘paged’ => $loop->query_vars[‘paged’] from your $pagination array. It’s not a parameter in the docs. Remove the ‘base’ => @add_query_arg(‘paged’,’%#%’) from your $pagination array. I believe WordPress catches the paged parameter using the default page parameter. Which is it’s default. Here are the docs for the … Read more

pagination: Only one result is shown even if there are more than one?

Lets clean this up: <h2> <?php $num = $wp_query->post_count; if (have_posts()) :?> <a href=”https://wordpress.stackexchange.com/questions/190595/<?php the_permalink(); ?>”><?php the_title();?></a> <?php endif;?> <?php $search_count = 0; $search = new WP_Query(“s=$s & showposts=5”); if($search->have_posts()) : while($search->have_posts()) : $search->the_post(); $search_count++; endwhile; else : ?> <?php next_posts_link(); ?> <?php previous_posts_link(); ?> <p> there were no results </p> <?php endif;?> </h2> Lets … Read more

Best way to include pagination in a theme [closed]

Paginations mostly rely on the global $wp_query variable to generate the data. Using get_posts() will not generate that, because it returns an array of posts, not an instance of the WP_Query() class itself. As a result, you don’t have access to class’s methods, such as $query->max_num_pages. You can use a plugin to add pagination (such … Read more