[Resolved] Pagination Custom Post Type Child Theme

  • Author
    Posts
  • #10031

    MC
    Participant

    we have the pro version of ultra. trying to get pagination working in a child theme while using custom post type. Is there documentation or advice? thanks

    #10033

    Puro Support
    Keymaster

    Hi MC

    Ultra is using the_posts_pagination so WordPress should be handling that.

    https://codex.wordpress.org/Function_Reference/the_posts_pagination

    If you think the child theme may be a factor, switch to the parent theme and test.

    Here is a demo custom post type: https://demo.purothemes.com/ultra/services/. You can see the pagination is working normally.

    Are you using Ultra 1.3.1?

    Have you gone to Settings > Permalinks and clicked Save?

    What is the problem that you’re seeing specifically?

    #10039

    MC
    Participant

    I’m using the latest version. permalinks are set.

    page is here

    Newswire

    pagination does not fire.

    this is the code for page that pulls the data:
    <div class=”listing-page”>
    <?php
    $posttype = ‘lda’;
    $args = array(
    ‘posts_per_page’ => 6,
    ‘post_type’ => $posttype,
    ‘post_status’ => ‘publish’,
    ‘orderby’ => ‘post_date’,
    ‘order’ => ‘DESC’,
    ‘lda_category’ => ‘lda-newsire’,
    ‘post_status’ => ‘publish’,
    “nopaging” => false,
    “paged” => get_query_var(‘page’)
    );
    $posts_array = new WP_Query( $args );

    if ( $posts_array->have_posts() ) :
    while ( $posts_array->have_posts() ) : $posts_array->the_post();
    $permalink = get_the_permalink();
    ?>
    <div class=”post-<?php the_ID(); ?> post type-post status-publish format-standard hentry category-blog”>
    <h2>
    “>
    <?php the_title();?>

    </h2>
    <?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    the_post_thumbnail(‘medium’,[‘class’ => ‘img-responsive custom_post_img’]);
    }
    ?>
    <div class=”post-content”>
    <p>
    <?php
    $excerpt = get_the_excerpt();
    echo $excerpt;
    ?>
    </p>
    </div>
    <p class=”readmore”>” title=”<?php the_title(); ?>”>Read more …</p>
    </div>
    <!–post–>

    <?php endwhile; ?>
    <div class=”pagination”>
    <?php the_posts_pagination(); ?>
    </div>
    <?php wp_reset_query(); ?>
    <?php endif; ?>

    </div>
    <!–listing-page–>

    #10040

    Puro Support
    Keymaster

    Thanks for your feedback. Please, try temporarily switching to the parent theme and test to see if the problem persists.

    #10041

    MC
    Participant

    tested it but it then no data is displayed because I have a custom function to use a shortcode

    function newswire() {
    global $content;
    global $wpdb;
    ob_start();
    include ‘include/newswire.php’;
    $output = ob_get_clean();
    return $output;
    }
    add_shortcode( ‘newswire’, ‘newswire’ );

    maybe you have a better way.

    #10042

    Puro Support
    Keymaster

    Ideally, we need to try and find a working benchmark. Do you have any ideas? Does this work with Twenty Sixteen for example? Is there a problem with Ultra or your customization missing functionality?

    #10043

    MC
    Participant

    if I could see how you do it on your demo page, I could apply that to mine.
    https://demo.purothemes.com/ultra/services/.

    how you call the custom type.

    #10044

    Puro Support
    Keymaster

    I’m using the SiteOrigin Premium Custom Post Type Builder for that demo. I just wanted to show that at a base level, the default pagination function works with a custom post type.

    #10045

    Puro Support
    Keymaster

    Is the custom loop necessary? Does the post type not having a default archive structure? That’s what we’re using with the demo, no extra files, we’re using the default structure.

    #10046

    MC
    Participant

    I’ll research their documentation and see if I can apply it here. thanks.

    #10047

    Puro Support
    Keymaster

    Can you send a link to those docs?

    #10048

    MC
    Participant
    #10049

    Puro Support
    Keymaster

    Are you using SiteOrigin Premium to create the custom post type?

    #10050

    MC
    Participant

    I am not, just hardcode the shortcode then the shortcode in the page. so if I have a custom post type ‘newswire’ how to display that in an archive?

    #10051

    Puro Support
    Keymaster

    Thanks for the update. The SiteOrigin docs, unfortunately, wouldn’t be applicable then.

    Which plugin is creating the custom post type? Do you have a link to the newswire plugin, it’s those docs I was asking for a link to. Sorry for the confusion.

    When a plugin creates a custom post type, it chooses whether or not to add the archive page. When you create a custom post type manually, there is an argument for the archive page:

    'has_archive' => true,

    If the post type is called newswire and if the plugin handling this has the above argument set to true then there should be an archive page without any customizing.

    Can you send a link to the plugin?

Viewing 15 posts - 1 through 15 (of 27 total)

You must be logged in to reply to this topic.

Scroll to top