Pagination issue in my wordpress custom page template - wordpress

I am using this code for pagination but on the front its showing only pagination link like this "« Previous 1 2 3 4 … 10 Next »" and showing all post(content) in a single page when i click on other pagination link then it showing same post(content) on every link
<?php while( have_rows( 'press' ) ): the_row();
$row++;
// Ignore this image if $row is lower than $min
if($row < $min) { continue; }
// Stop loop completely if $row is higher than $max
if($row > $max) { break; } ?>
<?php
$img_obj = get_field('press');
foreach($img_obj as $press) :
?>
<div class="col-lg-4 col-md-6">
<div class="press-post-wrapper">
<div class="press-post-image">
<img src="<?php echo $press['image']; ?>" alt="<?php echo $press['publication']; ?>">
</div>
<div class="metaData">
<span class="pDate"><?php echo $press['publication'].','?>
<?php echo get_the_date('Y/m/d'); ?></span>
</div>
<div class="press-post-description">
<p><?php echo $press['description']; ?></p>
</div>
</div>
</div>
<?php endforeach; endwhile; ?>
</div>
<?php
// Pagination
echo paginate_links( array(
'base' => get_permalink() . 'page/%#%' . '/', 'format' => '?paged=%#%',
'current' => $page,
'total' => $pages
) );
?>

Related

Getting multiple copies of images when using WP_query to display custom post

I'm using WP-query to display my 3 most recent 'events' which are a custom post type.
Visually it looks like its working fine, but after doing some debugging I noticed that the same image is being loaded 4 times for each post.
<div class="container">
<?php
$args = array(
'post_type' => 'projects',
'posts_per_page' => '2'
);
$the_query = new WP_Query( $args );
$count = $the_query->post_count;
?>
<div class="row small-up-1 medium-up-2 large-up-<?php echo $count ?>" data-equalizer="news" data-equalize-on-stack="false" data-equalize-on="medium">
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<div class="column">
<div class="card">
<div class="card-divider" data-equalizer-watch="news">
<h4> <?php the_title(); ?></h4>
<?php
// FLEXIBLE CONTENT NAME
if( have_rows('main_sections') ):
// FLEXIBLE CONTENT NAME
while ( have_rows('main_sections') ) : the_row(); ?>
<?php // LAYOUT NAME
if( get_row_layout() == 'standard_details' ): ?>
<?php if( get_sub_field('date_of_event') ):
$field_name1 = "date_of_event";
$field1 = get_sub_field_object($field_name1);
?>
<p><?php echo $field1['value']; ?></p>
<?php endif; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php the_excerpt(__('(more…)')); ?>
</div>
<?php if ( 'video' == get_post_format() ) { ?>
<div class="video-icon">
<i class="fa fa-play fa-3x" aria-hidden="true"></i>
<?php } ?>
<a href="<?php the_permalink() ?>">
<img data-interchange="[<?php echo the_post_thumbnail_url('recent-news'); ?>, small]" alt="<?php the_title(); ?>" />
</a>
</div>
</div>
<?php
endwhile;
wp_reset_postdata();
?>
</div>
</div>
</div>

how to add pagination in wordpress

I have posts in different custom taxonomies. I need to display posts for one taxonomy in a page. Now I'm getting the all the posts in all taxonomies in a single page. I have a foreach loop for taxonomy and inside the loop all the posts corresponding to that taxonomy is displaying through post method.I have never used pagination before. How can I add pagination in this case?
I am enclosing my code below
<div class="main">
<section class="brands-sec product-sec">
<div class="container">
<?php
$siteurl = home_url('/');
$tax = 'product'; // slug of taxonomy
$terms = get_terms($tax);
foreach ($terms as $term) {
$id = $term->term_id;
$slug = $term->slug;
$description = $term->description;
$image_url = z_taxonomy_image_url( $id, NULL, TRUE ); // category image display
$link = "<a href='$siteurl?$tax=$slug' ><h1> $term->name </h1></a>";
echo '<img src="' . $image_url . '">'; ?>
<div class="col-md-8 pull-right col-sm-10 pull-right col-xs-12 brnd prdct">
<img src="<?php echo $image_url ; ?>" class="img-responsive pdt-logo" alt="loyd"/>
<div class="brand-logos pdt">
<p><?php echo $description ; ?></p>
<h4>Product</h4>
<?php $args = array("posts_per_page" => "-1", "product"=>$slug ,"post_type" => "products" );
$posts = get_posts($args);
foreach($posts as $data){
$thumb = wp_get_attachment_url( get_post_thumbnail_id($data ->ID) );
$custom_fonts = get_post_custom($data->ID);$custom_fonts_key= $custom_fonts['category'];$custom_fonts_array = $custom_fonts_key[0]; ?>
<div class="row mb40">
<div class="col-md-4 col-sm-4 col-xs-12 brand-single product-single">
<img src="<?php echo $thumb; ?>" class="img-responsive" alt="allegro products"/>
<h5><?php echo $data->post_title; ?></h5>
<p><?php echo $data->post_content; ?></p>
</div>
<div class="col-md-8 col-sm-8 col-xs-12 brand-single product-detail">
<ul class="products">
<?php
$attachments = new Attachments( 'my_attachments',$data->ID ); /* pass the instance name */ ?>
<?php if( $attachments->exist() ) : ?>
<?php while( $attachments->get() ) : ?>
<li><img src="<?php echo $attachments->url(); ?>" class="img-responsive" alt="allegro products"/></li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
</div>
<?php } ?>
</div><!--end brand-logos-->
</div><!--end brnd-->
<?php } ?>
</div>
Here product is custom taxonomy . In that there are more than one terms say loyd,Nycofee,.... In Both these terms there are more than one posts. I need to display posts in loyd in one page and ncofee in next page. How to add pagination in this case?
Try this:
You have the post_per_page to be -1
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array("posts_per_page" => "-1", "product"=>$slug ,"post_type" => "products" );
change it to the number you would like. and add to the end
'paged' => $paged
before Ending the PHP here
</div>
<?php } ?>
</div><!--end brand-logos-->
Add
<?php if (function_exists('wp_pagenavi')) wp_pagenavi(array('query' => $args )); ?>
<?php wp_reset_postdata(); ?>
Here is the basic pagination for wordpress
<?php if ( have_posts() ) : ?>
<!-- Add the pagination functions here. -->
<!-- Start of the main loop. -->
<?php while ( have_posts() ) : the_post(); ?>
<!-- the rest of your theme's main loop -->
<?php endwhile; ?>
<!-- End of the main loop -->
<!-- Add the pagination functions here. -->
<div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
Soruce: https://codex.wordpress.org/Pagination "Example Loop with Pagination"
If it still show the full list.
Try this: http://callmenick.com/post/custom-wordpress-loop-with-pagination

List custom taxonomies by custom field

Below I have my custom taxonomy template and its working fine until now.
<?php
/*
Template Name: Performer List Page
*/
get_header(); ?>
<?php
// if show all is set
$sortby=$_GET['sortby'];
if( isset($_GET['showall']) || isset($sortby) ):
$args = array( 'hide_empty' => 0 );
else:
// else show paged
$page = ( get_query_var('paged') ) ? get_query_var( 'paged' ) : 1;
global $framework_opt,$post; $number_of_performers = $framework_opt['performers_per_page'];
$orderby = 'date';
$order = isset( $_REQUEST['order'] ) ? trim( $_REQUEST['order'] ) : null;
if(isset($_GET['order']) && !empty($_GET['order'])) {
switch($order)
{
case 'alphabetically' : $orderby = 'title';
break;
case 'popularity' : $orderby = 'count';
break;
/*
case 'female' : $meta = 'gazi_female';
break;
case 'male' : $meta = 'gazi_male';
break;
*/
default : $orderby = 'date';
break;
}
}
// number of tags to show per-page
$per_page = $number_of_performers ;
$offset = ( $page-1 ) * $per_page;
$args = array( 'orderby' => $orderby, 'number' => $per_page, 'meta_key' => $meta, 'offset' => $offset, 'hide_empty' => 0 );
endif;
$taxonomy = 'performer';
$count_performers = wp_count_terms( $taxonomy, $offset );
$tax_terms = get_terms( $taxonomy, $args );
?>
<aside class="sidebar pull-left">
<p class="sidebar-title"><?php _e( 'SEARCH BY LETTER', 'gazi' ); ?></p>
<div class="letter-search clearfix">
<span class="letter">A</span>
<span class="letter">B</span>
<span class="letter">C</span>
<span class="letter" style="width:40%"><?php _e( 'All', 'gazi' ); ?></span>
<span class="letter" style="width:40%"><?php _e( 'Reset', 'gazi' ); ?></span>
</div>
<!--<p class="sidebar-title"><?php _e( 'QUICK SEARCH', 'gazi' ); ?></p>
<form class="frm-search-tag has-title" action="<?php echo home_url( '/' ); ?>" method="get">
<input type="text" placeholder="Search name" name="s" value="" />
<button type="submit"><span class="ico ico-search"></span>
<select class="search_tools" style="display:none;" name="taxonomy" >
<option value="performer">Videos</option>
<option value="gallery">Photos</option>
</select>
</button>
</form>-->
<div style="height: 5px;"></div>
<?php get_template_part( 'templates/sidebars/performer-sidebar', get_post_format() ); ?>
</aside>
<section class="main-section pull-left">
<div class="page-title with-sorter clearfix">
<h1><?php the_title(); ?></h1>
<div class="info hidden-mobile">
<p>
<?php echo $count_performers; ?><?php _e( 'Performers', 'gazi' ); ?> <span class="ico ico-tv"></span>
</p>
<div class="sorter">
<div class="dropdown-container">
<ul class="flyout-menu flyout-menu-right">
<li>
<button class="dropdown-toggle" type="button" data-action="dropdown-toggle" data-target="#sorter-dropdown">SORT</button>
<div class="flyout-menu-content" id="sorter-dropdown">
<ul class="flyout-menu-items">
<li>
<?php _e( 'Alphabetically', 'gazi' ); ?> </li>
<li>
<?php _e( 'Popularity', 'gazi' ); ?> </li>
</ul>
</div>
</li>
</ul>
</div></div> </div>
<div class="info visible-mobile clearfix">
<button class="btn-pd btn-pd-primary pull-left" style="margin-right: 0;" data-action="scroll-to" data-target="#letter-search">A-Z</button>
<p style="float:right">
<?php echo $wp_query->found_posts; ?> <?php _e( 'Performers', 'gazi' ); ?> <span class="ico ico-tv"></span></p>
</div></div>
<div id="performer-list" class="list-view">
<div id="performer-thumbs" class="performer-listing clearfix">
<div class="items">
<?php foreach ($tax_terms as $cat) : ?>
<?php
$flag = 0;
if( $sortby == substr( $cat->name, 0, 1 ) || $sortby=='' ) { $flag = 1;}
if ($flag=='1'){
?>
<article class="performer-item">
<a class="outline" href="<?php echo get_term_link($cat->slug, 'performer'); ?>" title="<?php echo $cat->name; ?>">
<?php $performer_image = z_taxonomy_image_url($cat->term_id); if(!empty($performer_image)) : ?>
<img src="<?php bloginfo('template_directory'); ?>/gazi/css/images/1pixel.gif" data-src="<?php echo z_taxonomy_image_url($cat->term_id,NULL, array(180, 240)); ?>" alt="<?php echo $cat->name; ?>" />
<noscript><img src="<?php echo z_taxonomy_image_url($cat->term_id,NULL, array(180, 240)); ?>" alt="<?php echo $cat->name; ?>" /></noscript>
<?php else : ?>
<img src="<?php bloginfo('template_directory'); ?>/gazi/css/images/1pixel.gif" data-src="<?php bloginfo('template_directory'); ?>/gazi/css/images/no-img-women.jpg" alt="<?php echo $cat->name; ?>" />
<noscript><img src="<?php bloginfo('template_directory'); ?>/gazi/css/images/no-img-women.jpg" alt="<?php echo $cat->name; ?>" /></noscript>
<?php endif; ?>
<span class="performer-name"><?php echo $cat->name; ?></span>
<span class="performer-videos hidden-mobile">
<span class="count"><?php echo $cat->count; ?></span>
<span class="txt"><?php _e( 'VIDEOS', 'gazi' ); ?></span>
</span>
</a>
<div class="performer-item-footer visible-mobile">
<span class="ico ico-take"></span> <?php echo $cat->count; ?> <?php _e( 'VIDEOS', 'gazi' ); ?> </div>
</article>
<?php } ?>
<?php endforeach; ?>
</div>
</div>
<?php
if( isset($_GET['showall']) || isset($sortby)):
echo '';
else:
// showall is set, show link to get back to paged mode
$total_terms = wp_count_terms( 'performer' );
$pages = ceil($total_terms/$per_page);
// if there's more than one page
if( $pages > 1 ):
echo '<div class="pager"><div class="paginator" id="performer_paginator">';
for ($pagecount=1; $pagecount <= $pages; $pagecount++):
echo '<a class="page" href="'.get_permalink().'page/'.$pagecount.'/"><span>'.$pagecount.'</span></a>';
endfor;
// link to show all
echo '<a class="page" href="'.get_permalink().'?showall=true">ALL</a>';
echo '</div>';
endif;
endif;
?>
</div>
<div id="letter-search" class="visible-mobile">
<div class="section-title with-sorter clearfix" style="margin-bottom: 4px;">
<p class="title">Letters Search</p>
<div class="info">
<button class="btn-pd btn-pd-sm btn-pd-primary pull-right" data-action="scroll-to" data-target="#performer-thumbs"><span class="ico ico-grid"></span></button>
</div>
</div>
<div class="letter-search clearfix">
<span class="letter">A</span>
<span class="letter">B</span>
<span class="letter">C</span>
</div>
</div>
<?php get_template_part( 'templates/advertisements_bottom', get_post_format() ); ?>
</section>
<?php get_footer(); ?>
If you see I added an order menu for popularity and videos count for this listing is working but under the order code you will see:
/*
case 'female' : $meta = 'gazi_female';
break;
case 'male' : $meta = 'gazi_male';
break;
*/
so I want to separate performers by male and female using the custom fields above.Any one that has any idea how to complete this template?
thanks
You want to show results based on meta field 'gazi_female' or 'gazi_male' so you should include in your meta_query arguments.
Instead of 'meta_key' => $meta use meta_query. Meta query in get_terms feature got introduced from 4.4.0 version, so make sure your version supports it with get_terms()
You should not use it in order_by parameter since order_by will sort the results and it cant filter results.
Alternatively try WP_Term_Query which is available from 4.6 versions
// WP_Term_Query arguments
$args = array (
'taxonomy' => array( 'performer' ),
'meta_key' => 'male',
'meta_value' => 'gazi_male',
);
// The Term Query
$term_query = new WP_Term_Query( $args );
// The Loop
if ( ! empty( $term_query ) && ! is_wp_error( $term_query ) ) {
// do something
} else {
// no terms found
}

All posts on page of one category

I really can't figure this out. I'm trying to have posts all posts on a page from one category, but I still get all categories. This is the code I'm using now. I thought I could manage with WP_Query( array( 'posts_per_page' => -1, 'category_name' => 'resep' ) );, but it totally drives me nuts.
<?php /* Template Name: Blog */ ?>
<?php get_header(); ?>
<div id="content-wrap">
<div id="content">
<div class="post_content">
<h1 class="archive_title"><?php the_title(); ?></h1>
<?php
$query['post_type'] = 'post';
// WP 3.0 PAGED BUG FIX
if ( get_query_var('paged') )
$paged = get_query_var('paged');
elseif ( get_query_var('page') )
$paged = get_query_var('page');
else
$paged = 1;
//$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query['paged'] = $paged;
$recipe_posts = new WP_Query( array( 'posts_per_page' => -1, 'category_name' => 'resep' ) );
while ( $recipe_posts->have_posts() ) { $recipe_posts->the_post(); }
query_posts($query);
if (have_posts()) : ?>
<?php $more = 0; ?>
<div class="posts">
<?php while (have_posts()) : the_post();
$is_recipe = in_category('Resep'); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?>>
<?php if (option::get('index_thumb') == 'on') {
get_the_image( array( 'size' => 'loop', 'width' => option::get('thumb_width'), 'height' => option::get('thumb_height'), 'before' => '<div class="post-thumb">', 'after' => '</div>' ) );
} ?>
<div class="details">
<h2 class="title"><?php the_title(); ?></h2>
<?php if ( option::get('display_meta') == 'on' ) { ?>
<div class="meta">
<?php
if ( $is_recipe ) {
$fields = get_fields();
if ( !empty( $fields ) ) echo $fields;
} else { ?>
<p><strong><img src="<?php echo get_template_directory_uri() . '/images/person.png'; ?>" /><?php _e('Author', 'wpzoom'); ?>:</strong><?php the_author_posts_link(); ?></p>
<p><strong><img src="<?php echo get_template_directory_uri() . '/images/clock.png'; ?>" />
<?php _e('Posted', 'wpzoom'); ?>
:</strong> <?php echo get_the_date(); ?></p>
<?php } ?>
</div>
<?php } ?>
<div class="entry">
<?php the_content('<span>'.__('Read More', 'wpzoom').' ›</span>'); ?>
</div>
<p>
<?php if ( option::get('display_readmore') == 'on' && (option::get('display_content') == 'Excerpt') ) { ?>
<a href="<?php the_permalink(); ?>" class=" clean more-link">
<?php _e( ( $is_recipe ? 'Lihat Resep' : 'Read More' ), 'wpzoom' ); ?>
</a>
<?php } ?>
<?php edit_post_link( __('Edit', 'wpzoom'), ' <small>', '</small>' ); ?>
</p>
</div>
<div class="cleaner"> </div>
</div>
<!-- /.post -->
<?php endwhile; ?>
</div>
<div class="cleaner"> </div>
<?php get_template_part( 'pagination' ); ?>
<?php wp_reset_query(); ?>
<div class="cleaner"> </div>
<?php endif; ?>
</div><!-- / .post_content -->
</div><!-- / #content -->
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
You're making it far too complex, just specificy the stuff you need inside the while loop:
$recipe_posts = new WP_Query( array( 'posts_per_page' => -1, 'category_name' => 'resep' ) );
while ( $recipe_posts->have_posts() ) {
$recipe_posts->the_post();
echo '<li>' . get_the_title() . '</li>';
}
wp_reset_query();
You have entered loop inside loop, try this following with cleaning your code:
$args = array('posts_per_page' => -1 , 'category_name' => 'resep');
$recipe_posts = new WP_Query($args);
if($recipe_posts->have_posts()) :
while($recipe_posts->have_posts()) :
$recipe_posts->the_post();
?>
<h1><?php the_title() ?></h1>
<div class='post-content'><?php the_content() ?></div>
<?php
endwhile;
else:
?>
Oops, there are no posts.
<?php
endif;
?>
I cleaned the whole template, but posts from other categories were still there. In the end I managed with these lines
global $wp_query;
$args = array_merge( $wp_query->query, array( 'category_name' => 'resep' ) );
query_posts( $args );
$recipe_posts = new WP_Query($args);
$more = 0;
if($recipe_posts->have_posts()) :
while ($recipe_posts->have_posts()) : $recipe_posts->the_post();?>

Wordpress page won't paginate

Okay I am ripping my hair out over this and I know it is super simple and is staring me in the face but I just can't see it. In essence what is happening is that my pagination isn't working. I use the plugin wp_pagenavi (which is not the issue already checked) It gives me a list of links of each page in the pagination. That all works fine, in fact all the code does what it is supposed to do. The problem is when I click on the pagination link such as "2" or "3" it attempts to go to the corresponding pagination ie www.yousitehere.com/somepage/page/2 but instead the site just reloads the current page without the /page/2.
I think somewhere the page either doesn't realize it needs to paginate and therefore ignores all instances of /page or something is resetting the pagination before the page loads. (its not the reset_query).
This is a Wordpress site. Unfortunately I am unable to show the site link which makes it harder for you bu hopefully someone has a suggestion.
here is my code
<div id="content" class="clearfix">
<div id="main" class="col960 left first clearfix" role="cont_detail">
<?php if (have_posts()) : while (have_posts()) : the_post();
$id = get_the_ID();
$array = metadata($id);
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="cont_detail" >
<header>
<div id="header_bg_top"></div>
<div id="header_bg">
<?php if($array['custom_facebook'] !="" && $array['custom_twitter'] !="" && $array['custom_linkedin'] != ""&& $array['custom_website'] != "" && $array['custom_blog'] != "" && $array['custom_email'] != ""){?>
<div class="social_link_container">
<div class="width">
<?php if(isset($array['custom_facebook']) && $array['custom_facebook'] !=""){?>
<img src="<?php echo get_template_directory_uri(); ?>/images/author-facebook.png">
<?php }
if(isset($array['custom_twitter']) && $array['custom_twitter'] !=""){?>
<img src="<?php echo get_template_directory_uri(); ?>/images/author-twitter.png">
<?php }
if(isset($array['custom_linkedin']) && $array['custom_linkedin'] !=""){?>
<img src="<?php echo get_template_directory_uri(); ?>/images/author-in.png">
<?php }
if(isset($array['custom_website']) && $array['custom_website'] !=""){?>
<img src="<?php echo get_template_directory_uri(); ?>/images/author-web.png">
<?php }
if(isset($array['custom_blog']) && $array['custom_blog'] !=""){?>
<img src="<?php echo get_template_directory_uri(); ?>/images/author-blog.png">
<?php }
if(isset($array['custom_email']) && $array['custom_email'] !=""){?>
<img src="<?php echo get_template_directory_uri(); ?>/images/author-email.png"><?php }?>
</div>
</div>
<?php } ?>
<h1 class="cont_detail_title" itemprop="headline"><?php the_title(); ?></h1>
<?php if(isset($array['custom_description']) && $array['custom_description'] !="")
{
?>
<span class="title_description"><?php echo $array['custom_description']; ?></span>
<?php
}
?>
</div><!-- header-bg -->
</header> <!-- end article header -->
<section>
<div class="content-left">
<?php if(isset($array['featured_thumb']) && $array['featured_thumb'] !="")
{
?>
<div class="cont_detail_image">
<?php print_thumbnail($array['featured_thumb'], "medium");?>
</div>
<?php
}
?>
</div>
<div class="content-right">
<?php the_content(); ?>
</div>
</section> <!-- end article section -->
</article> <!-- end article -->
<?php endwhile; ?>
<?php else : ?>
<article id="post-not-found">
<header>
<h1>Not Found</h1>
</header>
<section class="post_content">
<p>Sorry, but the requested resource was not found on this site.</p>
</section>
<footer>
</footer>
</article>
<?php endif;
wp_reset_query();
//Sort queries, most viewed, alphabetical, date
echo '<section><div id="content_bg" class="group">';
$row_num = 1;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if( $_GET['sort'] == 'date' ) {
$sortOrder = getSortOrder( $_GET['dsort_order'] );
$meta_queries[] = array(
'key' => 'custom_authorid',
'value' => $post->ID,
'compare' => 'LIKE',
);
query_posts(array(
'post__not_in' => array($post->ID),
'post_type' => 'post',
'meta_query' => $meta_queries,
'order'=>$sortOrder,
'orderby'=> 'date',
'posts_per_page' => 9,
'paged' => $paged
));
}
elseif( $_GET['sort'] == 'alpha' ) {
$sortOrder = getSortOrder( $_GET['asort_order'] );
$meta_queries[] = array(
'key' => 'custom_authorid',
'value' => $post->ID,
'compare' => 'LIKE',
);
query_posts(array(
'post__not_in' => array($post->ID),
'post_type' => 'post',
'meta_query' => $meta_queries,
'order'=>$sortOrder,
'orderby'=> 'title',
// adding posts_per_page, set to 9 might be different then global preference
'posts_per_page' => 9,
'paged' => $paged
));
}
elseif( $_GET['sort'] == 'mviewed' ) {
}
else{
$meta_queries[] = array(
'key' => 'custom_authorid',
'value' => $post->ID,
'compare' => 'LIKE',
);
query_posts(array(
'post__not_in' => array($post->ID),
'post_type' => 'post',
'posts_per_page' => 9,
'meta_query' => $meta_queries,
'paged' => $paged
));
}
?>
<div class="paginate_nav">
<?php wp_pagenavi(); // use the page navi function ?>
<div class="sort_nav">
<?php contrPaginationLinks( $sortOrder ) ?>
</div><!--sort_nav-->
</div><!--paginate_nav-->
<?php
if( $_GET['sort'] == 'mviewed' ) {
}
else{
if (have_posts()) : while (have_posts()) : the_post();
$item = metadata($post->ID);
$containsVideos = false;
foreach ($item['cat'] as $value) {
if (strpos($value->cat_name,'Videos') !== false) {
$containsVideos = true;
}
}
?>
<div class="story-container" >
<div class="story_left">
<div class="story_image">
<input type="hidden" name="vidID" value="<?php echo $item['media_link']; ?>" />
<div class="about_latest_image <?php echo $item['media_link']; ?>">
<a href="<?php echo $item['link']; ?>">
<?php
print_thumbnail($item['featured_thumb'],"thumbnail", $item['youtube_link'], $item['vimeo_link'], $item['media_link']);
?>
<?php if($containsVideos == true){echo '<span class="videoIndicator"></span>';} ?>
</a>
</div>
</div>
<?php if($_GET['sort'] == 'date'){ ?>
<div class="story_view">
<?php echo $item['date']; ?>
</div>
<?php } ?>
</div>
<div class="story_title">
<a href="<?php echo $item['link']; ?>" title="<?php echo $item['title']; ?>">
<span class="story_title"><?php echo $item['title']; ?></span>
</a>
</div>
<?php if(isset($item['custom_description']) && $item['custom_description'] !="") {
?>
<div class="story_description"><?php echo $item['custom_description']; ?></div>
<?php
}
?>
<div class="story_content"></div>
</div>
<?php endwhile; ?>
<?php else : ?>
<h1><?php _e("No Posts Yet", "hooplahatheme"); ?></h1>
<p><?php _e("Sorry, What you were looking for is not here.", "hooplahatheme"); ?></p>
<?php endif;
} // end display else default
echo '</div></section>';
//
// reset query after display is done
//
wp_reset_query();
?>
<footer>
</footer> <!-- end article footer -->
</div> <!-- end #main -->
Update
It turns out that there is a 302 redirect occurring which is what I am trying to find out the next step.
Christopher's answer probably works for most people.
But..
If you want to stop the redirect from also affecting /pagename/page/1, this will help:
add_filter('redirect_canonical', 'my_redirect_canonical', 10, 2);
function my_redirect_canonical($redirect_url, $requested_url) {
$do_redirect = true;
if(preg_match('/page/',$requested_url)){
$do_redirect = false;
}
return $do_redirect;
}
Found here.
So for anyone with a similar question the answer is simple. You can't paginate single post pages by default in wordpress. It will just redirect back to the root URL of the page. What you need to do to stop this is add this to your themes functions.php
add_filter('redirect_canonical','pif_disable_redirect_canonical');
function pif_disable_redirect_canonical($redirect_url) {
if( is_singular() && in_category('PLACE CAT ID HERE') ) {
$redirect_url = false;
}
return $redirect_url;
}
for more info on this you can look here http://wordpress.org/support/topic/home-pagination-page2-redirect-to-a-post

Resources