- This topic has 26 replies, 2 voices, and was last updated 6 years, 5 months ago by Puro Support.
- AuthorPosts
- June 20, 2018 at 7:42 pm #10031
MCParticipantwe 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
June 20, 2018 at 10:06 pm #10033
Puro SupportKeymasterHi 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?
June 21, 2018 at 7:05 pm #10039
MCParticipantI’m using the latest version. permalinks are set.
page is here
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–>June 21, 2018 at 7:32 pm #10040
Puro SupportKeymasterThanks for your feedback. Please, try temporarily switching to the parent theme and test to see if the problem persists.
June 21, 2018 at 7:35 pm #10041
MCParticipanttested 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.
June 21, 2018 at 7:41 pm #10042
Puro SupportKeymasterIdeally, 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?
June 21, 2018 at 7:44 pm #10043
MCParticipantif 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.
June 21, 2018 at 7:47 pm #10044
Puro SupportKeymasterI’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.
June 21, 2018 at 7:49 pm #10045
Puro SupportKeymasterIs 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.
June 21, 2018 at 7:49 pm #10046
MCParticipantI’ll research their documentation and see if I can apply it here. thanks.
June 21, 2018 at 7:50 pm #10047
Puro SupportKeymasterCan you send a link to those docs?
June 21, 2018 at 7:50 pm #10048
MCParticipantJune 21, 2018 at 7:51 pm #10049
Puro SupportKeymasterAre you using SiteOrigin Premium to create the custom post type?
June 21, 2018 at 7:53 pm #10050
MCParticipantI 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?
June 21, 2018 at 7:57 pm #10051
Puro SupportKeymasterThanks 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 totrue
then there should be an archive page without any customizing.Can you send a link to the plugin?
- AuthorPosts
You must be logged in to reply to this topic.