#StackBounty: #magento2 #url #pagination Is there any way to remove pagination ID from URL?

Bounty: 50

I’m wondering Like, Is there any way to remove Pagination Page ID from URL?

Like, I moved to the second page or any other page during listing page.

SO URL will be changed as default behavior of Magento as

https://www.example.com/cat-url.html?p=2

How to remove p=2?

Every Suggestions appreciated.

UPDATE

I’m using custom module to load products on category page via Ajax.

https://amasty.com/infinite-scroll-for-magento-2.html

Thanks in Advance.


Get this bounty!!!

#StackBounty: #custom-post-types #posts #pagination #query-posts Use WP pagination functions on a custom page template

Bounty: 100

I have a custom page template, I’m using a standard WPQuery to fetch the posts from the default posts custom post type. I’m looping through all the posts however now I have more posts than I allow in the settings of the admin. Instead of changing the limit I want to use some standard WP pagination. However, none of the functions work on a custom page template but do when used on index.php.

<?php /* Template Name: News page */
get_header(); ?>
<?php $args = array(
    'post_type'  => array( 'post' ),
  );

  // The Query
  $query = new WP_Query( $args ); ?>

I’ve used the previous_posts_link() function as a test but nothing is returned in the dom.

Is it possible to use standard wp pagination on custom page templates?


Get this bounty!!!

#StackBounty: #pagination How to make WP Query Pagination work

Bounty: 50

There seem to be countless custom query pagination questions on here, so glad to know I’m not the only one struggling with it. Have tried following the answers in those questions but so far no luck.

I have a custom post type, say Galleries. Each post has a title, and an Advanced Custom Field Gallery field that includes images. When on one of those posts currently it shows the linked titles for the first 12 posts to the right of the images. This means you never get to see past the 12th. I could change the 12 to -1 to show all, but list would go on for a while.

Hoping to add pagination, so if you are on the first post, under the list on the right would said, “more” and would take you to the 13th post, and the list on the right would now show linked titles for 13 to 24. And there would be a prev button and a more button. Prev would go back to first page and show 1 12 titles, and more would take you to 25th post and show 25 to 36 and so on.

I’ve tried adding pagination in various way to accomplish that but with no luck. Some questions I thought looked right but gave errors. Is pagination the right way, or should I be developing a custom if else statements or such to accomplish this?

<?php get_header(); ?>      

  


Get this bounty!!!

#StackBounty: #pages #pagination #search #paginate-links Custom Search Page Pagination Not Working

Bounty: 50

My Seach Page URLs:

https://www.example.com/search/keyword/page/2/

Here my custom search page:

<?php 

    if($_GET['search_text'] && !empty($_GET['search_text']))
    {
        $text = $_GET['search_text'];
    }
    else
    {
        $text = urldecode( get_query_var('search_text') ) ;            
    }

?>

Arama Sonuçları:
'product', 'posts_per_page' => 2, 'paged' => $paged, 'post__in' => $my_products ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); wc_get_template_part( 'content', 'product' ); endwhile; $total_pages = $loop->max_num_pages; if ($total_pages > 1){ /* $current_page = max(1, get_query_var('paged')); */ $wp_query->query_vars['paged'] > 1 ? $current_page = $wp_query->query_vars['paged'] : $current_page = 1; echo $wp_query->query_vars['paged']; echo paginate_links(array( 'base' => get_pagenum_link(1) . '%_%', 'format' => '/page/%#%', 'current' => $current_page, 'total' => $total_pages, 'prev_text' => __('« prev'), 'next_text' => __('next »'), )); } } wp_reset_postdata(); ?>
</div> </main><!-- #main --> </div><!-- #primary -->

My pagination links are created fine, but I always see the page No 1 because somehow query_vars['paged'] is emtpy.

I have seen Preserving Search Page Results and Pagination section on this page , but couldn’t figure it out how to use it, but I don’t think this is really needed in my case.

Let me know if you need anything else.


Get this bounty!!!

#StackBounty: #wordpress #pagination #template #woocommerce How can I use pagination in Woocommerce with a list of known product IDs?

Bounty: 50

when I click to a product tag in woocommerce (example: cats), it goes to the landing page (mysite.com/product-tag/cats/) which uses template (product-archieve.php), and that template creates a products page with pagination.

I have examined contents of product-archieve.php but I couldn’t figure out how it works, by checking the code.

I have an array of product ids, and I want to list my products with same kind of pagination, How can I achieve this?


Get this bounty!!!

#StackBounty: #magento-1.9 #catalog #pagination Pagination Not Showing on Category Pages – Magento 1

Bounty: 50

For some reason, Pagination is not showing on all of our category pages.

I’ve looked at other question on here and from what I’ve learned you need the page/html_pager block within catalog.xml for the category.

In this file we have a few instances of and they all have this page/html_pager block.

Any ideas why the pagination is not showing?


Get this bounty!!!

#StackBounty: #wp-query #pagination #search #forms Pagination not working for Custom search form & custom result template

Bounty: 50

I am using custom search form and custom template to display the results according to the solution given in here
Everything is working perfect except the pagination which doesn’t seem to work at all

Overview

  • Custom post type : job_listing
  • Custom taxonomy : job_listing_type
  • custom fields as key: _job_location

Here is the code for search form :

<form method="get" id="advanced-searchform" role="search" action="<?php echo esc_url( home_url( '/' ) ); ?>">
    <input type="hidden" name="search" value="advanced">

        <select id="my-select1" class="js-example-basic-single isotopeselect" data-filter-group="proyectos" multiple="multiple" name="terms[]">

        <?php foreach ($job_terms as $job_term): ?>
          <option value=".<?php echo str_replace(' ', '-', str_replace('&', 'and', html_entity_decode($job_term)));?>"><?php echo $job_term;?></option>
        <?php endforeach; ?>

        </select>    
        <button type="submit"><span>search</span></button>
    <input type="hidden" name="job_listing" value=""/>
</form>

Here is the search result template

<?php 
get_header();
$terms=array();
$all=($_REQUEST); 


if(isset($_REQUEST["terms"])){
    $myterms=$all["terms"];
    foreach ($myterms as $myterm) {
    $myterm=str_replace(".","",$myterm);
    $terms[]=$myterm;    
    }
}

if($terms){
    $tax_query[] =  array(
                        array(
                        'taxonomy' => 'job_listing_type',
                        'field' => 'name',
                        'terms' => $terms
                      ) );
}

$post_type = 'job_listing';
$paged= (get_query_var('paged' )) ? get_query_var('paged'):1;
$args         =  array(
    'paged'=>$paged,
    'post_type'=>$post_type,
    'posts_per_page'=>1, 
    'tax_query' => $tax_query,
    );
$loop = new WP_Query( $args );     
if($loop->have_posts()):?>

    
have_posts()):$loop->the_post(); the_title(); endwhile; ?>
<?php endif; ?> <?php wp_reset_query();?> <?php get_footer(); ?>

Result on initial search, url is like

http://example.com/?search=advanced&terms%5B%5D=.Eat&job_listing=

After i hit next then url becomes

http://example.com/page/2/?search=advanced&terms%5B0%5D=.Eat&job_listing

but nothing happens, result remains same

I have never done this before so please help me out on this


Get this bounty!!!

#StackBounty: #php #templates #pagination Static Frontpage Pagination – Custom loop

Bounty: 100

I created a custom content template, assigned it to a page and coded the query.

Everything appears to be working as they should. The only issue I have is with the pagination. So, when I go the second page I get a “No posts were found.”

What I’ve tried so far:

  • I set another paginated grid (3rd party plugin) as a homepage.
    Fiddling with the pagination of that plugin gave me the same
    devastating result.

This is my source

            <?php
            if ( get_query_var('paged') ) {
                 $paged = get_query_var('paged');
                 } elseif ( get_query_var('page') ) {
                 $paged = get_query_var('page');
                 } else {
                 $paged = 1;
                 }
              $args=array(
                 'post_type' => 'gadget',
                 'post_status' => 'publish',
                 'posts_per_page' => 36,
                 'paged' => $paged,
                 'nopaging' => false
                );

              $fp_query = null;
              $fp_query = new WP_Query($args);

              if( $fp_query->have_posts() ) {

                $i = 0;
                while ($fp_query->have_posts()) : $fp_query->the_post();
                global $post;
                $postidlt = get_the_id($post->ID);

              // modified to work with 3 columns
              // output an open 
if($i % 3 == 0) { ?>
">
"true", "url"=>"true","id"=>"$postidlt")); } ?>);">
,
"FIELD_NAME : $ FIELD_VALUE", "id"=>"$postidlt")); if($discountbg) : ?>
<?php endif; ?> <!-- Video Condition -->
<!-- Crowdfunding Condition --> <?php if ( has_term('crowdfunding', 'gadget-categories', $post->ID) ): ?>
<?php endif; ?> </div> </div> </a> </div>
</div>
"FIELD_NAME : $ FIELD_VALUE", "id"=>"$postidlt")); $discountedprice = types_render_field("discount", array("style" => "FIELD_NAME : $ FIELD_VALUE", "id"=>"$postidlt")); $tba = types_render_field("tba-n", array("output" => "raw", "id"=>"$postidlt")); $currency = types_render_field("currency", array()); if ($initalprice && empty($discountedprice) && empty($tba)) { echo($currency),($initalprice); } elseif ($discountedprice && empty($tba)) { echo($currency),($discountedprice); } elseif ($tba) { echo("TBA"); } ?>
ID , 'gadget_categories' ); foreach ( $terms as $index => $term ) { if ($index == 0) { // The $term is an object, so we don't need to specify the $taxonomy. $term_link = get_term_link( $term ); // If there was an error, continue to the next term. if ( is_wp_error( $term_link ) ) { continue; } // We successfully got a link. Print it out. echo '' . $term->name . ''; } } ?> ID , 'gadget_categories' ); echo '
'; foreach ( $terms_rst as $index => $term ) { if ($index > 0) { // The $term is an object, so we don't need to specify the $taxonomy. $term_link = get_term_link( $term ); // If there was an error, continue to the next term. if ( is_wp_error( $term_link ) ) { continue; } // We successfully got a link. Print it out. echo '' . $term->name . ''; } } echo '
'; ?> </div> </div> </div>
</div>
true ); do_action('gd_mylist_btn',$arg); ?>
</div> </div>
</div> </div> <?php $i++; // Closing the grid row div if($i != 0 && $i % 3 == 0) { ?> </div><!--/.row-->
<?php } ?> <!-- Random Category Snippet Generation --> <?php if( $i % 12 == 0 ) { $max = 1; //number of categories to display $taxonomy = 'gadget_categories'; $terms = get_terms($taxonomy, 'orderby=name&order= ASC&hide_empty=0'); // Random order shuffle($terms); // Get first $max items $terms = array_slice($terms, 0, $max); // Sort by name usort($terms, function($a, $b){ return strcasecmp($a->name, $b->name); }); // Echo random terms sorted alphabetically if ($terms) { foreach($terms as $term) { $termID = $term->term_id; echo '
$termID, "output" =>"raw") ).')">
'; } } } ?> <?php endwhile; } wp_reset_postdata(); ?>

You can see a live representation of the issue by visiting this link and clicking on “Newer Posts” at the bottom of the page.

EDIT

You can see that at the moment there is a lazyloader at the bottom of the page. Using this template I almost achieved the desired result here. However, I still get nothing on the frontpage (keep in mind that the frontpage and the page I provided before are using the same exact template.


Get this bounty!!!

#StackBounty: #pagination #meta-value #wp-comment-query Custom WP_Comment_Query with pagination and orderby?

Bounty: 50

I’m trying to setup a custom WP_Comment_Query which is ordered by a meta key. (It might be worth mentioning that these comments are being retrieved with AJAX.)

It all works fine, until I add in pagination into the query args.

$orderby = 'top-comments';

$args = array(
    'post_id' => $post_id,
    'type' => 'comment',
    'status' => 'approve',
    'hierarchical' => true
);

if ( $orderby == 'top-comments' ) {
    $args['meta_key'] = 'comment_rating';
    $args['orderby'] = 'meta_value_num';
    $args['order'] = 'ASC';
}

// $comments_query = new WP_Comment_Query;
// $comments = $comments_query->query($args);

// Works fine up until I add the pagination args

$number = 5;
$paged = 1;
$offset = ( $paged - 1 ) * $number;

$args['number'] = $number;
$args['paged'] = $paged;
$args['offset'] = $offset;

$comments_query = new WP_Comment_Query;
$comments = $comments_query->query($args);

// Gets the 5 latest comments, then orders those by meta_key

The results without the pagination args works perfect, and orders the comments exactly how I want it.

However, once the number argument is set, it will retrieve the newest 5 comments, and then order them by meta_key => 'comment_rating'.

The behaviour I expect is WP_Comment_Query first applying the orderby, and then returning the top 5 results.

What am I doing wrong?


Get this bounty!!!

#StackBounty: #angular2 #pagination #ag-grid #ag-grid-ng2 ag grid pagination, grid is not loading

Bounty: 50

Clicking on search button on the page will return result from server call and should display that in the ag grid.
Each click pagination details are seinding server will return only that much records to client.

Implemented ag grid but grid is not loading after clicking on search. Can you help me to figure out where I’m doing wrong.

This is the html, grid section and search button.

 <form [formGroup]="myForm" >
   
--Select-- {{category.catDesc}}
</div> <button type="submit" class="btn btn-default">Search</button> </div> </div> </form> </div>
0">

Component

export class ISearchComponent {
    myForm: FormGroup;
    rowData: Array<IncidentHeaderModel> = new Array<IncidentHeaderModel>();
    gridOptions = <GridOptions>{
        context: {},
        rowModelType: 'pagination',
        enableServerSideFilter: true,
        paginationPageSize: 10

    };

    //defining the headers
    columnDefs:any[] = [
        {headerName: 'Status', field: 'incidentStatus.value'},
        {headerName: 'Category', field: 'categoryMast.catDesc'},
        {headerName: 'Sub Category', field: 'subCategoryMast.subCatDesc'},
        {headerName: 'Location', field: 'location.locName'},
        {headerName: 'Time', field: 'incidentTime'},
        {headerName: 'Delay(Hrs)', cellRenderer:this.getDelayInHours}

    ];


    constructor(private masterDataService:MasterDataService,private http: Http) {
        this.myForm = new FormGroup({
        'catCode'   : new FormControl()

    }  

//when this data source get invoked

   dataSource = {
       pageSize: 10,
        getRows: (params: any) => {
          console.log("here dataSource")
                this.searchIncident(params.startRow, params.endRow); // returns json from server
                var rowsThisPage = this.rowData;
                var lastRow = -1;
                if (rowsThisPage.length <= params.endRow) {
                    lastRow = rowsThisPage.length;
                }
              params.successCallback(rowsThisPage, lastRow);
        }
     }

//server call and returns the json data.

searchIncident(start:number, end:number){


  myJson['firstResult'] = start;
  myJson.maxResult = this.gridOptions.paginationPageSize;

   this.http.post(AppUtils.INCIDENT_SEARCH, this.myForm.value, {headers: headers}).subscribe(res=>{
             this.rowData = res.json().result;
     console.log("@@@@" +JSON.stringify(this.rowData));
         }, err=>{             
         });

    }
}

Tried solution(not working)

invoking the grid on search button click like this

 private search() {
     this.gridOptions.api.setDatasource(this.dataSource);
   }

I had added data source to enable server side pagination, then how can I invoke that data source ?

Any help in ag-grid pagination ? How to load data source ?

added plunker http://plnkr.co/edit/qIeONaAe4INyTuZTGAOK?open=app%2Fapp.component.ts&p=preview


Get this bounty!!!