Resolved

Pagination Custom Post Type Child Theme

Ultra Theme started by MC Jun 20, 2018 26 replies
MC Jun 20, 2018 · 7:42 pm #10031

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

Puro Support Puro Jun 20, 2018 · 10:06 pm #10033

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?

MC Jun 21, 2018 · 7:05 pm #10039

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

page is here
https://dev.ies.org/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–>

Puro Support Puro Jun 21, 2018 · 7:32 pm #10040

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

MC Jun 21, 2018 · 7:35 pm #10041

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.

Puro Support Puro Jun 21, 2018 · 7:41 pm #10042

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?

Puro Support Puro Jun 21, 2018 · 7:47 pm #10044

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.

Puro Support Puro Jun 21, 2018 · 7:49 pm #10045

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.

MC Jun 21, 2018 · 7:49 pm #10046

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

Puro Support Puro Jun 21, 2018 · 7:50 pm #10047

Can you send a link to those docs?

Puro Support Puro Jun 21, 2018 · 7:51 pm #10049

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

MC Jun 21, 2018 · 7:53 pm #10050

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?

Puro Support Puro Jun 21, 2018 · 7:57 pm #10051

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?

27 posts