java – Pagination by combining two query results

There are currently two query lists, let’s assume one is List queryList1 and List queryList2, where

Line1: queryList1 = dao.get(someParams); 
Line2: queryList2 = dao.get(differentParams);

I can execute Line 2 based on the following conditions

if(queryList1.size() == request.size()) { //some computation with queryList2 }
if(queryList1.isEmpty()) { //some computation with queryList2}
if(queryList1.size() < request.size()) { //some computation with queryList2}

And this is how the computation in queryList2 looks like

if(queryList2.size() == request.size()) { //some computation  }
if(queryList2.isEmpty()) { //some computation}
if(queryList2.size() < request.size()) { //some computation }

So there a lot of conditional branching happening here, to do pagination for combination of two types of query results. Is there any better way to do this?

P.S. We can’t do a union on the query results by combining the dao layers. These two dao layer calls has to run separately on need basis

Example for Reference:

queryList1 = {C1, C2, C3, C4, C5}
queryList2 = {P1, P2, P3, P4, P5}
When: Pagination size is 3, I need to return 3 records every page
Page1 results: {C1, C2, C3}
Page2 results: {C4, C5, P1} -> if queryList1 size becomes less than page requested size or is equal to 0, only then fetch queryList2
Page3 results: {P2, P3, P4}

WordPress blog pagination not working

Please let me know if anyone know ..

 <?php
            $per_page = 6;
            $paged    = get_query_var('paged') ? : 1;
            $offset   = (1 === $paged) ? 0 : (($paged - 1) * $per_page) + (($paged - 1) * 2);
            
             $args = array(
            'post_type'=> 'post',
            'posts_per_page' => $per_page,
            'post_status' => 'publish',
            'order' => 'DESC',
            'orderby' => 'ID',
            'paged' => $paged,
            'author__not_in' => array(1),
            'offset' => $offset,
              'ignore_sticky_posts' => 1
            
            );
            $result = new WP_Query( $args );
                if ( $result-> have_posts() ) : ?>
                <?php while ( $result->have_posts() ) : $result->the_post(); ?>
                      
                                <div class="col-md-4 col-sm-12" style="float:left;">
                                    <div class="authorname">
                                     <?php //geting here post author name
                                        echo get_the_author(); 
                                        
                                      ?>
                                    </div>
                                           <h2 class="post_title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
                                            <div class="featured_image">
                                                <a href="<?php the_permalink() ?>">
                                                    <?php
                                                     the_post_thumbnail('full');
                                                     ?>
                                                 </a>
                                             </div>
                                             
                                           <div class="excerpt">
                                                <?php
                                                 $cats = get_the_category($id);
                                                
                                                // excerpt of post
                                                the_excerpt();
                                                
                                                ?>  
                                                
                                           </div>
                                           <div class="category_name">
                                               <?php foreach ( $cats as $cat ): ?>
                                                    <a href="<?php echo get_category_link($cat->cat_ID); ?>">
                                                        <?php echo $cat->name; echo ", "; ?>
                                                    </a>
                                                <?php endforeach; ?>
                                           </div>
                                </div>
                <?php endwhile; ?>
                            <!-- Pagination -->
                            <nav class="pagination">

max_num_pages);
if ($paged > 1) echo ‘ | ‘;
next_posts_link(‘More »’, $query->max_num_pages);

echo ‘
Showing ‘ . $offset . ‘-‘ . ($offset + 6) . ‘ of ‘ . $query->found_posts . ‘ posts.’;
?>

php – How to make a pagination with dropdown selection?

This is the code for the dropdown pagination. It uses a js controller too, but it works fine, so, I’m not adding it.

$total = $wp_query->max_num_pages;
// only bother with the rest if we have more than 1 page!
if ( $total > 1 )  {
    // get the current page
    if ( !$current_page = get_query_var('paged') ){
      $current_page = 1;
    }   
    // structure of "format" depends on whether we're using pretty permalinks
    $format = 'page/%#%/';
    $linkarray = paginate_links(array(
      'base' => str_replace( 'page/9999999/', '%_%', esc_url( get_pagenum_link( 9999999 ) ) ),
      'format' => $format,
      'current' => 0,
      'show_all' => true,
      'total' => $total,
      'mid_size' => 4,
      'prev_next' => False,
      'type' => 'array'
    ));
 
    $urlarray = array();
 
    foreach($linkarray as $value){
        $pieces = explode(' ',$value);
        foreach($pieces as $piece){
            if (substr(strtolower($piece),0,4) == 'http'){
                $urlarray() = $piece;
            }
        }
    }
 
    echo '<div style="text-align: center">(Or jump to page ';
    echo '<select id="paginationpageselectcontrol" name="paginationpageselectcontrol">' . "n";
    $pagecounter = 1;
    foreach($urlarray as $url){
        echo '<option value="' .  $url . '"' . (($pagecounter == $current_page)?' selected':'') . '>' . $pagecounter . '</option>' . "n";
        $pagecounter = $pagecounter + 1;
    }
    echo '</select>' . "n";
    echo ' of ' . $total . ')</div>';
}

I think the error is around here:


    $urlarray = array();
 
    foreach($linkarray as $value){
        $pieces = explode(' ',$value);
        foreach($pieces as $piece){
            if (substr(strtolower($piece),0,4) == 'http'){
                $urlarray() = $piece;
            }
        }
    }

magento 2.1 – Backend (Products / Catalog): Show all bundle items (no pagination please)

we need a better overview on the product page (edit mode) and need to view all bundle items without pagination (for better sorting). How can I disable pagination and show all bundle items of the (bundle) product? Is there a config file? Do I have to edit a script file? I’m a web developer so I don’t need a long explanation how to do it, I think – just a hint where to look at. Thanks for helping out!

pagination – Does an infinite-scroll page on its own url and a paginated page on another url with the same content hurt SEO?

The pages won’t compete in terms of SEO because Googlebot never scrolls the page. The only content that Googlebot ever sees in content displayed via the onload event. Any content that is only shown after user interaction (such as scrolling or clicking) needs its own URL with links to it if you want Google to find it.

When implementing infinite scroll it is important to ensure that one page of content appears before any user interaction. If you require that users scroll to see the first item, Google will see your first page as blank.

You need to make sure you link to your /posts permalinks so that Googlebot can find them via links on your site. Even if you expect users to mainly scroll to them, you need navigation to the URLs for the permanent location of the content that Googlebot can find. Just putting the permalinks in an XML sitemap is not sufficient for SEO. See The Sitemap Paradox.

You can change the URL using pushState as users scroll. As an article scrolls into position on your infinite page, you can change the URL in browser’s location bar without ever loading a new page. This allows users that scroll to an article to easily link to that article by copying and pasting the URL from the location bar. If you don’t do this, it could hurt SEO because more users end up linking to the home page rather than deep linking to specific content. The deep links are more helpful for SEO than links to your home page.

pagination – Does an infinite-scroll page one its own url and a paginated page on another url with the same content hurt SEO?

My index page is an infinite scrollable page.
I also have a paginated page on another url say /posts with the same content; like how SO’s index page and /questions page have the same content.

Will this negatively affect SEO? Will these pages compete for fame seo-wise?
If yes, how to prevent this while keeping the infinite-scroll effect.

customization – how to display next previous pagination on custom page?

I tried to add pagination my custom page, the pagination number appears but there is no next and previous pagination.

enter image description here

function.php

function pagination($pages = '', $range = 4)

{
$showitems = ($range * 2)+1;

global $paged;
if(empty($paged)) $paged = 1;

if($pages == '')
{
    global $wp_query;
    $pages = $wp_query->max_num_pages;
    if(!$pages)
    {
        $pages = 1;
    }
}

if(1 != $pages)
{
    echo "<ul class="pagination pagination-lg my-4 justify-content-center">";
    if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo; First</a>";
    if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo; Previous</a>";

    for ($i=1; $i <= $pages; $i++)
    {
        if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
        {
            echo ($paged == $i)? "<li class="page-item active"><a class="page-link" href='".get_pagenum_link($i)."'>".$i."</a></li>":"<li><a href='".get_pagenum_link($i)."' class="page-link">".$i."</a></li>";
        }
    }

    if ($paged < $pages && $showitems < $pages) echo "<li class="page-item"><a href="".get_pagenum_link($paged + 1)."" data-hover="Next" class="next page-link">»</a></li>";
    if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<li class="page-item"><a href='".get_pagenum_link($pages)."' data-hover="Previous" class="prev page-link">«</a>";
    echo "</ul>n";
}

}

popular.php

Popular Videos

‘post’,
‘posts_per_page’ => 20,
‘meta_key’ => ‘post_views_count’,
‘orderby’ => ‘meta_value_num’,
‘paged’ => $paged
);
$custom_query = new WP_Query( $args );
?>
have_posts()) :
$custom_query->the_post();
?>

“>

–>
‘video-img img-fluid’, ‘alt’ => get_the_title()));
}
?>

ID, ‘time’) ); ?>

” title=””>

99% –>

max_num_pages);
}
?>

sql – mysql security concerns and improving php pagination script

Hello I’m new to sql and php.i was trying to understand how a php pagination script works, i found a video on youtube which helped me understand it.this is the source code from that video,however i’ve got some questions :

-is this script good enough for displaying information on a site online?is there anyway to improve it?
-are there is security issues with it?

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Pagination</title>
</head>
<body>
<?php
// connect to database
$con = mysqli_connect('localhost','root','');
mysqli_select_db($con, 'pagination');

// define how many results you want per page
$results_per_page = 10;

// find out the number of results stored in database
$sql='SELECT * FROM alphabet';
$result = mysqli_query($con, $sql);
$number_of_results = mysqli_num_rows($result);

// determine number of total pages available
$number_of_pages = ceil($number_of_results/$results_per_page);

// determine which page number visitor is currently on
if (!isset($_GET('page'))) {
  $page = 1;
} else {
  $page = $_GET('page');
}

// determine the sql LIMIT starting number for the results on the displaying page
$this_page_first_result = ($page-1)*$results_per_page;

// retrieve selected results from database and display them on page
$sql='SELECT * FROM alphabet LIMIT ' . $this_page_first_result . ',' .  $results_per_page;
$result = mysqli_query($con, $sql);

while($row = mysqli_fetch_array($result)) {
  echo $row('id') . ' ' . $row('alphabet'). '<br>';
}

// display the links to the pages
for ($page=1;$page<=$number_of_pages;$page++) {
  echo '<a href="index.php?page=' . $page . '">' . $page . '</a> ';
}

?>
</body>
</html>

Display category name , category posts and create pagination using ajax [closed]

Display category name , category posts and create pagination by clicking on category name the related category posts need to show using ajax

Move to pagination with URL parameters

I can not find the way to use URL parameters to define pagination pages /posts?page=2 instead of the conventional WordPress way /posts/page/2/

The goal is to make WordPress change the way it manages pagination, without breaking the website that is using the conventional WordPress permalinks format

/posts/page/2/

and change the pagination to

/posts?page=2

I am happy also with this variant:

/posts/page/2?page=2

if necessary.