‘posts_per_page’ => ’10’ does not show any post

everybody,

I have created a custom_post_type;

function create_post_type_veranstaltungen()
{
register_post_type(‘veranstaltungen’, array(
‘label’ => __(‘Veranstaltungen’),
‘public’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘menu_icon’ => ‘dashicons-admin-site-alt’,
‘supports’ => array(‘thumbnail’, ‘title’, ‘editor’, ‘author’,
‘excerpt’, ‘comments’),
)
);
}
add_action(‘init’, ‘create_post_type_veranstaltungen’);

with its own section of taxonomies

function tr_create_my_taxonomy()
{

register_taxonomy(
‘veranstaltungen-category’,
‘veranstaltungen’,
array(
‘label’ => __(‘Category’),
‘rewrite’ => array(‘slug’ => ‘veranstaltungen-category’),
‘hierarchical’ => true,
)
);
}

add_action(‘init’, ‘tr_create_my_taxonomy’);

Then I created 4 post and I implemented the corresponding loop that works

<?php

$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;

$custom_args = array(
‘post_type’ => ‘veranstaltungen’,
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
‘paged’ => $paged,
‘posts_per_page’ => ’10’

);
$wp_query = new WP_Query($custom_args);

if (have_posts()) :
while (have_posts()) : the_post();

?>

<div class=”pagination”>
<?php
$big = 999999999; // need an unlikely integer

echo paginate_links(array(
base’ => str_replace($big, ‘%#%’, esc_url(get_pagenum_link($big))),
‘format’ => ‘?paged=%#%’,
‘current’ => max(1, get_query_var(‘paged’)),
‘total’ => $wp_query->max_num_pages
));
?>
</div>

if income posts_per_page => ‘-1’ works, if I enter posts_per_page => ‘1’ also works, but if I enter posts_per_page => ’10’ does not show anything at all.

Does anyone have an idea of what may be happening?

Thanks

Read more here:: ’10’ does not show any post” rel=nofollow>’posts_per_page’ => ’10’ does not show any post

Leave a Reply

Your email address will not be published. Required fields are marked *