Как решить проблему с нумерацией страниц плагина bbpress с помощью paginate_link()Php

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Как решить проблему с нумерацией страниц плагина bbpress с помощью paginate_link()

Сообщение Anonymous »

Поскольку у меня возникли трудности с созданием нумерации страниц. Я исследовал этот метод непосредственного добавления \includes\forums\template.php в плагин.

Код: Выделить всё

function bbp_has_forums( $args = array() ) {

// Forum archive only shows root
if ( bbp_is_forum_archive() ) {
$default_post_parent = 0;

// User subscriptions shows any
} elseif ( bbp_is_subscriptions() ) {
$default_post_parent = 'any';

// Could be anything, so look for possible parent ID
} else {
$default_post_parent = bbp_get_forum_id();
}

$default_forum_search = bbp_sanitize_search_request( 'fs' );

$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;

// Default argument array
$default = array(
'post_type'           => bbp_get_forum_post_type(),
'post_parent'         => $default_post_parent,
'post_status'         => bbp_get_public_status_id(),
'posts_per_page'      => get_option( '_bbp_forums_per_page', 50 ),
'orderby'             => 'menu_order title',
'order'               => 'ASC',
'no_found_rows'       => true,
'ignore_sticky_posts' => true,
'posts_per_page' => 7,
'paged' => $paged, // page number is defined here.
// Conditionally prime the cache for last active posts
'update_post_family_cache' => true
);

// Only add 's' arg if searching for forums
// See https://bbpress.trac.wordpress.org/ticket/2607
if ( ! empty( $default_forum_search ) ) {
$default['s'] = $default_forum_search;
}

// Parse arguments with default forum query for most circumstances
$r = bbp_parse_args( $args, $default, 'has_forums' );

// Run the query
$bbp              = bbpress();
$bbp->forum_query = new WP_Query( $r );

// Maybe prime last active posts
if ( ! empty( $r['update_post_family_cache'] ) ) {
bbp_update_post_family_caches( $bbp->forum_query->posts );
}
$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' =>  $bbp->forum_query->max_num_pages
));
// Filter & return

return apply_filters( 'bbp_has_forums', $bbp->forum_query->have_posts(), $bbp->forum_query );
}
Этого нет в function.php дочерней темы, поскольку это единственное место, где я могу это сделать, чтобы иметь возможность использовать paginate_links() везде, где я хочу, чтобы она отображалась. Или я что-то упускаю?
В архиве-форуме я сделал что-то подобное. Вызов — это повторение, хотя он работает путем вывода нумерации страниц, но только по умолчанию, т. е. 1,2 следующих или предыдущих 1,2, и если у меня есть больше страниц, я не могу получить paginate_links(); определенный в архиве-форуме, примите номер страницы.

Подробнее здесь: https://stackoverflow.com/questions/663 ... inate-link
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Php»