Как сделать чтобы работала Пагинация на статической странице?

Доброго времени суток.

Люди выручайте, очень прошу.

Создал статическую страницу и хочу вывести через элемент «Блог»конструктора WP Bakery Page Builder записи из нескольких категорий.

Записи из категорий выводятся, но при нажатии на пагинацию — главная страница обновляется и не листаются записи в цепочке пагинации.

Я нашел код данного элемента, который выводит записи.

 

Вот код:

<?php if ( ! defined( 'WOODMART_THEME_DIR' ) ) exit( 'No direct script access allowed' );
/**

* ------------------------------------------------------------------------------------------------

* Blog shortcode

* ------------------------------------------------------------------------------------------------

*/
if( ! function_exists( 'woodmart_shortcode_blog' ) ) {

function woodmart_shortcode_blog( $atts ) {
$parsed_atts = shortcode_atts( array(

'post_type' => 'post',

'include' => '',

'custom_query' => '',

'taxonomies' => '',

'pagination' => '',

'parts_media' => true,

'parts_title' => true,

'parts_meta' => true,

'parts_text' => true,

'parts_btn' => true,

'items_per_page' => 12,

'offset' => '',

'orderby' => 'date',

'order' => 'DESC',

'meta_key' => '',

'exclude' => '',

'class' => '',

'ajax_page' => '',

'img_size' => 'medium',

'blog_design' => 'default',

'blog_carousel_design' => 'masonry',

'blog_columns' => woodmart_get_opt( 'blog_columns' ),

'blog_spacing' => woodmart_get_opt( 'blog_spacing' ),

'speed' => '5000',

'slides_per_view' => '3',

'wrap' => '',

'autoplay' => 'no',

'hide_pagination_control' => '',

'hide_prev_next_buttons' => '',

'lazy_loading' => 'no',

'scroll_carousel_init' => 'no',

'scroll_per_page' => 'yes',

'search' => '',

), $atts );
extract( $parsed_atts );
$encoded_atts = json_encode( $parsed_atts );
$is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX );
$output = '';
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$id = uniqid();
if( $ajax_page > 1 ) $paged = $ajax_page;
$args = array(

'post_type' => 'post',

'post_status' => 'publish',

'paged' => $paged,

'posts_per_page' => $items_per_page,
);
if( $post_type == 'ids' && $include != '' ) {

$args['post__in'] = array_map('trim', explode(',', $include) );

}
if( ! empty( $exclude ) ) {

$args['post__not_in'] = array_map('trim', explode(',', $exclude) );

}
if( ! empty( $taxonomies ) ) {

$taxonomy_names = get_object_taxonomies( 'post' );

$terms = get_terms( $taxonomy_names, array(

'orderby' => 'name',

'include' => $taxonomies

) );
if( ! is_wp_error( $terms ) && ! empty( $terms ) ) {

$args['tax_query'] = array( 'relation' => 'OR' );

foreach ( $terms as $key => $term ) {

$args['tax_query'][] = array(

'taxonomy' => $term->taxonomy,

'field' => 'slug',

'terms' => array( $term->slug ),

'include_children' => true,

'operator' => 'IN'

);

}

}

}
if( ! empty( $order ) ) {

$args['order'] = $order;

}
if( ! empty( $offset ) ) {

$args['offset'] = $offset;

}
if( ! empty( $meta_key ) ) {

$args['meta_key'] = $meta_key;

}
if( ! empty( $orderby ) ) {

$args['orderby'] = $orderby;

}
if ( ! empty( $search ) ) {

$args['s'] = sanitize_text_field( $search );

}
$blog_query = new WP_Query( $args );
ob_start();
woodmart_set_loop_prop( 'blog_type', 'shortcode' );

woodmart_set_loop_prop( 'blog_design', $blog_design );

woodmart_set_loop_prop( 'img_size', $img_size );

woodmart_set_loop_prop( 'blog_columns', $blog_columns );

woodmart_set_loop_prop( 'woodmart_loop', 0 );

woodmart_set_loop_prop( 'parts_title', $parts_title );

woodmart_set_loop_prop( 'parts_meta', $parts_meta );

woodmart_set_loop_prop( 'parts_text', $parts_text );

woodmart_set_loop_prop( 'parts_media', $parts_media );
if ( $blog_design == 'carousel' ) {

woodmart_set_loop_prop( 'blog_design', $blog_carousel_design );

}
$parsed_atts['custom_sizes'] = apply_filters( 'woodmart_blog_shortcode_custom_sizes', false );
if( ! $parts_btn ) woodmart_set_loop_prop( 'parts_btn', false );
if( $blog_design == 'carousel' ) {

return woodmart_generate_posts_slider( $parsed_atts, $blog_query );

} else {
if ( $lazy_loading == 'yes' ) {

woodmart_lazy_loading_init( true );

}
if ( $blog_design == 'masonry' || $blog_design == 'mask' ) {

$class .= ' masonry-container';

woodmart_enqueue_script( 'isotope' );

woodmart_enqueue_script( 'woodmart-packery-mode' );

$class .= ' woodmart-spacing-' . $blog_spacing;

$class .= ' row';

}
$class .= ' blog-pagination-' . $pagination;
if( ! $is_ajax ) echo '<div class="woodmart-blog-holder blog-shortcode ' . esc_attr( $class ) . '" id="' . esc_attr( $id ) . '" data-paged="1" data-atts="' . esc_attr( $encoded_atts ) . '" data-source="shortcode">';
while ( $blog_query->have_posts() ) {

$blog_query->the_post();
get_template_part( 'content' );

}
if( ! $is_ajax ) echo '</div>';
if ( $blog_query->max_num_pages > 1 && ! $is_ajax && $pagination ) {

?>

<div class="blog-footer">

<?php if ( $pagination == 'infinit' || $pagination == 'more-btn' ): ?>

<a href="#" data-holder-id="<?php echo esc_attr( $id ); ?>" rel="nofollow" class="btn woodmart-load-more woodmart-blog-load-more load-on-<?php echo 'more-btn' === $pagination ? 'click' : 'scroll'; ?>"><span class="load-more-label"><?php esc_html_e( 'Load more posts', 'woodmart' ); ?></span><span class="load-more-loading"><?php esc_html_e( 'Loading...', 'woodmart' ); ?></span></a>

<?php else: ?>

<?php query_pagination( $blog_query->max_num_pages ); ?>

<?php endif ?>

</div>

<?php

}
}
wp_reset_postdata();
woodmart_reset_loop();
if ( $lazy_loading == 'yes' ) {

woodmart_lazy_loading_deinit();

}
$output .= ob_get_clean();
if( $is_ajax ) {

$output = array(

'items' => $output,

'status' => ( $blog_query->max_num_pages > $paged ) ? 'have-posts' : 'no-more-posts'

);

}
return $output;
}

}
if ( ! function_exists( 'woodmart_breadcrumbs' ) ) {

function woodmart_breadcrumbs() {
/* === OPTIONS === */

$text['home'] = esc_html__( 'Home', 'woodmart' ); // text for the 'Home' link

$text['category'] = esc_html__( 'Archive by Category "%s"', 'woodmart' ); // text for a category page

$text['search'] = esc_html__( 'Search Results for "%s" Query', 'woodmart' ); // text for a search results page

$text['tag'] = esc_html__( 'Posts Tagged "%s"', 'woodmart' ); // text for a tag page

$text['author'] = esc_html__( 'Articles Posted by %s', 'woodmart' ); // text for an author page

$text['404'] = esc_html__( 'Error 404', 'woodmart' ); // text for the 404 page
$show_current_post = 0; // 1 - show current post

$show_current = 1; // 1 - show current post/page/category title in breadcrumbs, 0 - don't show

$show_on_home = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show

$show_home_link = 1; // 1 - show the 'Home' link, 0 - don't show

$show_title = 1; // 1 - show the title for the links, 0 - don't show

$delimiter = ' &raquo; '; // delimiter between crumbs

$before = '<span class="current">'; // tag before the current crumb

$after = '</span>'; // tag after the current crumb

/* === END OF OPTIONS === */
global $post;
$home_link = home_url( '/' );

$link_before = '<span typeof="v:Breadcrumb">';

$link_after = '</span>';

$link_attr = ' rel="v:url" property="v:title"';

$link = $link_before . '<a' . $link_attr . ' href="%1$s">%2$s</a>' . $link_after;

$parent_id = $parent_id_2 = ( ! empty( $post ) && is_a( $post, 'WP_Post' ) ) ? $post->post_parent : 0;

$frontpage_id = get_option( 'page_on_front' );

$projects_id = woodmart_tpl2id( 'portfolio.php' );
if ( is_home() || is_front_page() ) {
if ( $show_on_home == 1 ) {

echo '<div class="breadcrumbs"><a href="' . $home_link . '">' . $text['home'] . '</a></div>';

}

} else {
echo '<div class="breadcrumbs" xmlns:v="http://rdf.data-vocabulary.org/#">';

if ( $show_home_link == 1 ) {

echo '<a href="' . $home_link . '" rel="v:url" property="v:title">' . $text['home'] . '</a>';

if ( $frontpage_id == 0 || $parent_id != $frontpage_id ) {

echo esc_html( $delimiter );

}

}
if ( is_category() ) {

$this_cat = get_category( get_query_var( 'cat' ), false );

if ( $this_cat->parent != 0 ) {

$cats = get_category_parents( $this_cat->parent, true, $delimiter );

if ( $show_current == 0 ) {

$cats = preg_replace( "#^(.+)$delimiter$#", '$1', $cats );

}

$cats = str_replace( '<a', $link_before . '<a' . $link_attr, $cats );

$cats = str_replace( '</a>', '</a>' . $link_after, $cats );

if ( $show_title == 0 ) {

$cats = preg_replace( '/ title="(.*?)"/', '', $cats );

}

echo wp_kses_post( $cats );

}

if ( $show_current == 1 ) {

echo wp_kses_post( $before ) . sprintf( $text['category'], single_cat_title( '', false ) ) . wp_kses_post( $after );

}

} elseif ( is_tax( 'project-cat' ) ) {

printf( $link, get_the_permalink( $projects_id ), get_the_title( $projects_id ) );

} elseif ( is_search() ) {

echo wp_kses_post( $before ) . sprintf( $text['search'], get_search_query() ) . wp_kses_post( $after );
} elseif ( is_day() ) {

echo sprintf( $link, get_year_link( get_the_time( 'Y' ) ), get_the_time( 'Y' ) ) . $delimiter;

echo sprintf( $link, get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ), get_the_time( 'F' ) ) . $delimiter;

echo wp_kses_post( $before ) . get_the_time( 'd' ) . wp_kses_post( $after );
} elseif ( is_month() ) {

echo sprintf( $link, get_year_link( get_the_time( 'Y' ) ), get_the_time( 'Y' ) ) . $delimiter;

echo wp_kses_post( $before ) . get_the_time( 'F' ) . wp_kses_post( $after );
} elseif ( is_year() ) {

echo wp_kses_post( $before ) . get_the_time( 'Y' ) . wp_kses_post( $after );
} elseif ( is_single() && ! is_attachment() ) {

if ( get_post_type() == 'portfolio' ) {

printf( $link, get_the_permalink( $projects_id ), get_the_title( $projects_id ) );

if ( $show_current == 1 ) {

echo esc_html( $delimiter ) . $before . get_the_title() . $after;

}

} elseif ( get_post_type() != 'post' ) {

$post_type = get_post_type_object( get_post_type() );

$slug = $post_type->rewrite;

printf( $link, $home_link . $slug['slug'] . '/', $post_type->labels->singular_name );

if ( $show_current == 1 ) {

echo esc_html( $delimiter ) . $before . get_the_title() . $after;

}

} else {

$cat = get_the_category();

if ( $cat && isset( $cat[0] ) ) {

$cat = $cat[0];

$cats = get_category_parents( $cat, true, $delimiter );

if ( $show_current == 0 ) {

$cats = preg_replace( "#^(.+)$delimiter$#", '$1', $cats );

}

$cats = str_replace( '<a', $link_before . '<a' . $link_attr, $cats );

$cats = str_replace( '</a>', '</a>' . $link_after, $cats );

if ( $show_title == 0 ) {

$cats = preg_replace( '/ title="(.*?)"/', '', $cats );

}

echo wp_kses_post( $cats );

if ( $show_current_post == 1 ) {

echo wp_kses_post( $before ) . get_the_title() . wp_kses_post( $after );

}

}

}

} elseif ( ! is_single() && ! is_page() && get_post_type() != 'post' && ! is_404() ) {

$post_type = get_post_type_object( get_post_type() );

if ( is_object( $post_type ) ) {

echo wp_kses_post( $before ) . $post_type->labels->singular_name . wp_kses_post( $after );

}

} elseif ( is_attachment() ) {

$parent = get_post( $parent_id );

$cat = get_the_category( $parent->ID );

$cat = $cat[0];

if ( $cat ) {

$cats = get_category_parents( $cat, true, $delimiter );

$cats = str_replace( '<a', $link_before . '<a' . $link_attr, $cats );

$cats = str_replace( '</a>', '</a>' . $link_after, $cats );

if ( $show_title == 0 ) {

$cats = preg_replace( '/ title="(.*?)"/', '', $cats );

}

echo wp_kses_post( $cats );

}

printf( $link, get_permalink( $parent ), $parent->post_title );

if ( $show_current == 1 ) {

echo esc_html( $delimiter ) . $before . get_the_title() . $after;

}

} elseif ( is_page() && ! $parent_id ) {

if ( $show_current == 1 ) {

echo wp_kses_post( $before ) . get_the_title() . wp_kses_post( $after );

}

} elseif ( is_page() && $parent_id ) {

if ( $parent_id != $frontpage_id ) {

$breadcrumbs = array();

while ( $parent_id ) {

$page = get_page( $parent_id );

if ( $parent_id != $frontpage_id ) {

$breadcrumbs[] = sprintf( $link, get_permalink( $page->ID ), get_the_title( $page->ID ) );

}

$parent_id = $page->post_parent;

}

$breadcrumbs = array_reverse( $breadcrumbs );

for ( $i = 0; $i < count( $breadcrumbs ); $i++ ) {

echo wp_kses_post( $breadcrumbs[ $i ] );

if ( $i != count( $breadcrumbs ) - 1 ) {

echo esc_html( $delimiter );

}

}

}

if ( $show_current == 1 ) {

if ( $show_home_link == 1 || ( $parent_id_2 != 0 && $parent_id_2 != $frontpage_id ) ) {

echo esc_html( $delimiter );

}

echo wp_kses_post( $before ) . get_the_title() . wp_kses_post( $after );

}

} elseif ( is_tag() ) {

echo wp_kses_post( $before ) . sprintf( $text['tag'], single_tag_title( '', false ) ) . wp_kses_post( $after );
} elseif ( is_author() ) {

global $author;

$userdata = get_userdata( $author );

echo wp_kses_post( $before ) . sprintf( $text['author'], $userdata->display_name ) . wp_kses_post( $after );
} elseif ( is_404() ) {

echo wp_kses_post( $before ) . $text['404'] . wp_kses_post( $after );
} elseif ( has_post_format() && ! is_singular() ) {

echo get_post_format_string( get_post_format() );

}
if ( get_query_var( 'paged' ) ) {

if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) {

echo ' (';

}

echo esc_html__( 'Page', 'woodmart' ) . ' ' . get_query_var( 'paged' );

if ( is_category() || is_day() ||

is_month() || is_year() || is_search() || is_tag() || is_author() ) {

echo ')';

}

}
echo '</div><!-- .breadcrumbs -->';
}

}

}

 

Добавить Комментарий

Ваш ответ

Размещая свой ответ, вы соглашаетесь с правилами сайта.