• Resolved devworlds

    (@devworlds)


    Hi,

    I have created a custom post type

    when i show my custom posts as a shortcode i’m not able to set there pagination.

    I have tried below code

    $paged = get_query_var('paged') ? get_query_var('paged') : 1;

    $args = array('post_type' => 'perks','posts_per_page' => $posts_per_page,'paged' => $paged,'orderby' => $orderby,order' => $order,'s' => $search);
    <?php while ($query->have_posts()) : $query->the_post(); ?>
    <div id="park-fullview" class="peksviewframe" data-id="<?php the_ID(); ?>">
    <div class="perk-imgsec">
    <?php
    $image = get_field('logo'); //acf field name
    if (!empty($image)) : ?>
    <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>"/>
    <?php endif; ?>
    </div>
    <h5 class="perks-coname"><?php the_field('company'); ?></h5>
    <span class="offer-dashed-border"><?php the_field('your_offer'); ?></span>
    </div>
    <?php endwhile; wp_reset_postdata(); ?>
    </div>
    <div class="pagination-controls">
    <?php
    echo paginate_links(array(
    'total' => $query->max_num_pages,
    'current' => $paged,
    'format' => 'page/%#%',
    'prev_text' => __('&laquo; Previous'),
    'next_text' => __('Next &raquo;'),
    ));
    ?>
    </div>


    <?php else : ?>
    <p>No perks found.</p>
    <?php endif; ?>
    </div>

    Pagination pages are coming but when i click next not working,

    On debug mode i see $paged value not changing. always showing 1 only.

    Please help me.

    thank you

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Custom Post Pagignation Not working with short code’ is closed to new replies.