Wordpress PageNavi Plugin not working in category.php

I tried different codes to be able to use the PageNavi Plugin in category.php, but all were not working. I don't know what was the problem? here is my working category.php code: <?php $cat = get_the_category(); $cat = $cat[0]; $catname = get_cat_name($cat->term_id); $catid = get_cat_ID($catname); ?> <?php $paged = get_query_var('paged', 1); $args = array( 'paged' => $paged, 'post_type' => 'post', 'cat' => $catid, ); $query = new WP_Query($args); global $query_string; query_posts( $query_string . "&posts_per_page=1&paged=".$paged ); while ( have_posts() ) : …
Category: Web

Different Limit number of post on different archive page

I set post per page from setting>maximum post per page to 20. I have 2 different custom post types 'book' and 'author' for archives of each of them. I want to load different number of post in page. I want to load 20 book per page in book archive and 5 post in author archive in each page. I also use WP-PageNavi plugin. Here is my code <?php $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $args …
Category: Web

Error 404 blog/page/2/

Hello i have problem. I can't view /blog/page/2/ i klick "_posts_link" and error 404 shows me Blog Page -> home.php <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array('posts_per_page' => 5, 'paged' => $currentPage); query_posts($args); if( have_posts() ): $i = 0; while( have_posts() ): the_post(); ?> <?php $i++; endwhile; ?> <ul class="uk-pagination uk-background-primary uk-light"> <li><?php next_posts_link('<span class="uk-margin-small-right" uk-pagination-previous></span> Stare Posty'); ?></li> <li class="uk-margin-auto-left"><?php previous_posts_link('Nowe posty <span class="uk-margin-small-left" uk-pagination-next>'); ?></li> </ul> <?php endif; wp_reset_query(); ?>
Category: Web

PageNavi redirects to 404 when used as archive page

I'm using a page as archive for a custom post type called event. register_post_type('event', array( 'labels' => array( 'name' => 'Événements', 'singular_name' => 'Événement', ), 'public' => true, 'has_archive' => false, 'hierarchical' => false, 'menu_icon' => 'dashicons-calendar-alt', 'rewrite' => array( 'with_front' => false, 'slug' => 'evenements' ) )); Then, I defined this page template to template-event.php, where I use the following code to loop through post types. $args = array( 'post_type' => 'event', 'posts_per_page' => 6, 'paged' => get_query_var('paged') ); …
Category: Web

Pagination not working with pagenavi

I am using PageNavi and have been searching around trying to figure out why I can't get pagination to work. Currently, the page numbers show but when you click on the page numbers, it goes to a page not found page. Here are some links I've reviewed: https://toolset.com/forums/topic/help-to-get-wp-pagenavi-working-for-page-2-onwards/ pagenavigation not showing the next page just linking back to the main page Here is my code: <?php /*Query DW Hammer Articles*/ $counter = 1; //counter tracks the number of the post …
Category: Web

wp_pagenavi() with custom wp_query()?

<?php /* Template Name: Projects */ ?> <?php get_header();?> <section id="content"> <section id="main"> <?php $loop = new WP_Query(array('post_type' => 'projects', 'posts_per_page' => 4)); $i=1; while ( $loop->have_posts() ) : $loop->the_post(); ?> <article class="post<?php if($i%2 == 0) { echo ' right'; }; $i++; ?>" id="post-<?php the_ID(); ?>"> <h2><?php the_title(); ?></h2> <section class="entry"> <?php the_excerpt(); ?> </section> </article> <?php endwhile; wp_pagenavi(); ?> <section id="map"> <img src="<?php bloginfo('template_url') ?>/images/interactive-map.jpg" alt="Interactive Map" /> </section> </section> <?php get_sidebar(); ?> </section> <?php get_footer(); ?> I have …
Category: Web

WP-PageNavi is showing the first page only

I am using WP-PageNavi plugin, which I incorporated into my custom tpl page. There is woocommerce shortcode which holds all the products that I want to display, but I only ever see the same ones and only one page results. I do not see what am I doing wrong. The code is: <?php /* Template Name: shine*/ ?> <?php get_header(); ?> <div class="wrapper clearfix"> <?php $args = array( 'post_type' => 'page', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => 5, …
Category: Web

Pagenavi with archive page

I have some problems in making wp_pagenavi works. I have a custom post archive page in which I activated the function. Here's the code: <?php // WP_Query arguments $args = array( 'post_type' => array( 'connazionali' ), 'nopaging' => false, 'paged' => '1', ); // The Query $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); the_title(); the_content(); } wp_pagenavi( array( 'query' => $query )); } else { // no …
Category: Web

Pagination URL in Custom Content Type

I have some custom content types on my WordPress website. In order to use pagination I am using wppagenavi plugin and it works fine except in a single custom content type page template that I create a custom query to show the related custom content types. It shows the pagination links correctly like below: Single Research Field Post: http://localhost/research-field/reports/ Url to the second page created by wppagenavi: http://localhost/research-field/reports/page/2 But when I click on the second page it redirects to the …
Category: Web

404 error next-page [2] PageNavi custom type taxonomy

I have a custom post type called pizza with a custom taxonomy called genero. mypage/pizza/peperoni/ When I click subsequent paginated page links (e.g. [2], [3], [next]) mypage/pizza/peperoni/page/2 The post is displayed correctly, but when I try to go to next-page [2], takes me to an 404 page my loop <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 2; $args = array( 'posts_per_page' => 2, 'order' => 'DESC', 'tax_query' => array( array( 'taxonomy' => 'genero', 'field' => 'slug', 'terms' => 'peperoni', 'paged' …
Category: Web

Pagination is not working on single-{slug}.php but works fine on page-{slug}.php

I would like to have my single-{slug}.php perform a query on a list of posts from different custom post type and use pagination. The pagination appears but unfortunately, clicking the pagination does not go to that page and always remains on page 1. Currently using WP-navi, btw. Example: Load the list of post from single-sports.php onto single-movies.php Any advice or help would be appreciated. Here's my single-{slug}.php: <?php $args = array( 'post_type' => 'crew', 'paged' => ( get_query_var('paged') ? get_query_var('paged') …
Category: Web

Pagination breaks on child-categories, works fine on parent-category

I have two parent categories, and pagination is working fine on them - the paged url's show as: /parent-category-1/page/2/ ... etc /parent-page/parent-category-2/page/2/ ... etc However, when I go to a child-category, pagination returns a 404 - for e.g.: /category/parent-category-1/child-category/page/2/ ... etc = 404 /category/parent-category-2/child-category/page/2/ ... etc = 404 I'm using the WP-PageNavi plugin for my pagination. I don't have any custom permalinks set in my permalinks options. parent-category-1 parents the categories for my standard blog posts. parent-category-2 parents the categories …
Category: Web

Ussing page_navi with WP_Query

I'm ussing in my site that code: category-anuncios.php <div class="listado-anuncios"> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $query=array("category_name"=>"anuncios","order"=>"ASC","posts_per_page"=>"1","page"=>$paged); $objAnuncio = new WP_Query($query); if ($objAnuncio->have_posts()){ ?> <ul> <?php while($objAnuncio->have_posts()){ $objAnuncio->the_post(); ?> <li> <?php the_title(); ?> </li> <?php } ?> </ul> <?php if (function_exists("wp_pagenavi")){wp_pagenavi(array("query"=>$objAnuncio));} wp_reset_postdata(); } ?> </div> I can see the content of my post well and show too the navigation...but, if I try to navigate to the second, third or other I have the error 404. How can use …
Category: Web

Menu Details Output in Javascript

I have to output page, parameters( Page Url, Page Name, and Page's featured image) in javascript loop, one by one I think we can display it through NavMenuItems or NavMenu functions Pages displayed will be those a user is allowed to see e by user hierarchy, Any suggestions on how to proceed...??
Category: Web

Article content navigator in wordpress like mbaskool website

Is there any way to allow navigation in an article within same post in Wordpress. or any such plugins ? Because i searched a lot, but could not find a way. For example : Check this link http://www.mbaskool.com/fun-corner/top-brand-lists/3457-top-10-automobile-brands-of-the-world-2012.html?start=6 where we can navigate through top 10 items of same post
Category: Web

WP Page Navi. 404 error when using posts per page parameter

I'm trying to fix an error with pagination of WP page Navi plugin. After I've added posts_per_page parameter to the query I'm getting 404 error when clicking on link page3,4 etc (there are 10 records totally) and after page 8 (where there around 60 records totally). Without this parameter it works fine but I want to display various number of posts under categories. Here is the code of one of the pages I'm trying to fix: $paged = (get_query_var('paged')) ? …
Category: Web

Pagination with wp_pagenavi not working on custom page

I am having trouble with wp_pagenavi working on the start page using a custom query. It's working well on every standard template like category.php. But not on the homepage. Here is the code: <?php $args=query_posts(array( 'post__not_in'=> array(419), 'post_type' => 'post', 'posts_per_page' => 10, 'paged' => get_query_var('page'), )); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php $featuredImage = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); $s1=strtolower($title); ?> <div id="post-<?php echo $post->ID;?>" <?php $item_format = is_video() ? 'video' : 'post'; …
Category: Web

Limit the number of posts via wpquery

We suppose that a category has 1000 posts, we can use the following code to show 10 posts per page and the wp pagenavi would present 100 pages with links of above 1000 posts. <?php query_posts($query_string."&showposts=10&orderby=date&order=ASC") ?> Is there any way that I show only 100 recent posts and hide remaining 900 posts because they may be too old? I used the numberpost but it did not work. My code is as follows: <?php query_posts($query_string."&showposts=10&numberposts=100&orderby=date&order=ASC") ?> <?php $mypage = (get_query_var('paged')) …
Category: Web

404 error PageNavi custom type taxonomy | wordpress

I have a custom post type called rock with a custom taxonomy called genero. taxonomy-genero-curiosity.php mypage/Rock/curiosity/ When i click subsequent paginated page links (e.g. [2], [3], [next]) mypage/Rock/curiosity/page/2 takes me to an 404 page. <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; //for a given post type, return all $args = array( 'tax_query' => array( array( 'taxonomy' => 'genero', 'field' => 'slug', 'terms' => 'curiosity' ) ), 'post_type'=>'', //add your post type name 'posts_per_page' …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.