Код: Выделить всё
$args = array(
'post_type' => 'portfolio',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => $num_posts,
);
$push_args = array_slice($args, 0, 2, true) + $stack + $stack_cat_all + array_slice($args, 2, count($args) - 1, true) ;
query_posts($push_args);
if($show_title == 'yes'){
$output = '';
$output .= ''.$element_title.'';
$output .= ''.$element_caption.'';
$output .= '';
}
global $paged;
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {$paged = 1;}
$args = array (
'post_type' => 'portfolio',
'posts_per_page' => $num_posts,
'post_status' => 'publish',
'paged' => $paged
);
$gallery_posts = new WP_Query($args);
if ( !empty($gallery_posts) ) {
if ($gallery_posts->have_posts()) {
while ($gallery_posts->have_posts()) {
$gallery_posts->the_post();
$terms = get_the_terms($post->ID, 'portfolio_category');
$links = array();
if (is_array($terms) || is_object($terms)) {
foreach ($terms as $term) {
$links[] = $term->name;
}
}
$links = str_replace(' ', '-', $links);
$tax = join(" ", $links);
$output .= '';
if ($thumbnail_position != 'below_title') {
if ($pretty_photo != 'no') {
$output .= '';
} else {
$output .= '';
}
}
if ($show_post_title != 'no') {
$output .= '' . get_the_title() . '';
}
if ($show_description != 'no') {
$output .= '
' . $content = substr(get_the_content(), 0, $num_characters) . '
';
}
if ($thumbnail_position == 'below_title') {
if ($pretty_photo != 'no') {
$output .= '';
} else {
$output .= '';
}
}
if ($read_more != '') {
$read_more = $read_more;
} else {
$read_more = 'Read More';
}
if (($show_post_title != 'no') && ($show_description != 'no')) {
$output .= '' . $read_more . '';
}
$output .= '';
}
$output .= '';
//$output .= paginate_links( $args );
if($show_pagination != 'no') {
$big = 999999999;
$output .= '' . paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $gallery_posts->max_num_pages
));
$output .= '';
}
wp_reset_query();
wp_reset_postdata();
return $output;
}
}}
Подробнее здесь: https://stackoverflow.com/questions/378 ... -structure