Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter MeindertHH

    (@meinderthh)

    To make it a bit more clear I made this example page.

    Code used:

    <?php require('wp/wp-blog-header.php');?>
    
    <!DOCTYPE HTML>
    <html>
    	<head>
        </head>
        <body>
    <?php
    // WP_Query arguments
    $args = array (
    	'pagination'             => true,
    	'posts_per_page'         => '3',
    	'order'                  => 'DESC',
    	'orderby'                => 'date',
    );
    // the query
    $the_query = new WP_Query( $args );
    ?>
    
    <?php if ( $the_query->have_posts() ) : ?>
    
    	<!-- pagination here -->
    
    	<!-- the loop -->
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post();         $cats = '';
    foreach( get_the_category( $recent["ID"] ) as $cat ) { $cats .= ' ' . $cat->slug; } ?>
    		<header><h4><?php   the_title(); ?></h4><p><?php the_date(); ?></p></header><p><?php the_content(); ?></p>
    	<?php endwhile; ?>
    	<!-- end of the loop -->
    
    	<!-- pagination here -->
    <?php
    $big = 999999999; // need an unlikely integer
    
    echo paginate_links( array(
    	'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    	'format' => '?paged=%#%',
    	'current' => max( 1, get_query_var('paged') ),
    	'total' => $the_query->max_num_pages
    ) );
    ?>
    	<?php wp_reset_postdata(); ?>
    
    <?php else : ?>
    	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>
        </body></html>

    I am very grateful if someone would help me.

    Thread Starter MeindertHH

    (@meinderthh)

    I maybe got a little bit closer…

    <?php
    // WP_Query arguments
    $args = array (
    	'pagination'             => true,
    	'posts_per_page'         => '5',
    	'order'                  => 'DESC',
    	'orderby'                => 'date',
    );
    // the query
    $the_query = new WP_Query( $args );
    ?>
    
    <?php if ( $the_query->have_posts() ) : ?>
    
    	<!-- pagination here -->
    
    	<!-- the loop -->
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<p>Title and content here</p>
    	<?php endwhile; ?>
    	<!-- end of the loop -->
    
    	<!-- pagination here -->
    <?php
    $big = 999999999; // need an unlikely integer
    
    echo paginate_links( array(
    	'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ),
    	'format' => '?paged=%#%',
    	'current' => max( 1, get_query_var('paged') ),
    	'total' => $the_query->max_num_pages
    ) );
    ?>
    	<?php wp_reset_postdata(); ?>
    
    <?php else : ?>
    	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>

    The problem is that esc_url( get_pagenum_link( $big ) ) sends me to my wordpress page. I want people to stay on my own domain. So ‘next page’ should redirect to mydomain.com/index.php?page=x.

    Anyone?

    Thanks!

    Thread Starter MeindertHH

    (@meinderthh)

    Thank you for the fast reply! Let me test it right away.

    Wow! It does exactly what I want! Thank you so much! ?? ??

Viewing 3 replies - 1 through 3 (of 3 total)