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
Pagination Custom Post Type Child Theme
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?
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–>
Thanks for your feedback. Please, try temporarily switching to the parent theme and test to see if the problem persists.
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.
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?
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.
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.
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.
I’ll research their documentation and see if I can apply it here. thanks.
Can you send a link to those docs?
Are you using SiteOrigin Premium to create the custom post type?
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?
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?
this is the plug that created the post type-