I am trying to figure out a Jupiter theme blog > components > blog-similar-posts.php code. I would like to show Related Posts instead of Recent Posts on the blog pages. What should I change in the following codes?
Here is the original code I have, thanks! I think I couldn't figure out the logistic between the $recent and $related. There might be something I changed wrong during the process
<?php
global $post, $mk_options;
if ($mk_options['enable_single_related_posts'] == 'true' && get_post_meta($post->ID, '_disable_related_posts', true) != 'false') :
$backup = $post;
$tags = wp_get_post_tags($post->ID);
$tagIDs = array();
$related_post_found = false;
$layout = get_post_meta($post->ID, '_layout', true);
$layout = !empty($layout) ? $layout : 'full';
$layout = ($layout == 'default') ? $mk_options['single_layout'] : $layout;
if ($layout == 'full') {
$showposts = 3; /* 4 before */
$width = ($mk_options['grid_width'] / 3 /* 4 before */) - 30;
$height = ($mk_options['grid_width'] / 3 /* 4 before */) - 80;
$column_css = 'three-cols' /* four-cols before */;
}
else {
$showposts = 3;
$width = (($mk_options['content_width'] / 100) * $mk_options['grid_width']) / 3;
$height = ((($mk_options['content_width'] / 100) * $mk_options['grid_width']) / 3) - 40;
$column_css = 'three-cols';
}
if (!function_exists('mk_similar_posts_html')) {
function mk_similar_posts_html($title, $width, $height, $column_css, $query) {
$output = '<section class="blog-similar-posts">';
$output.= '<div class="similar-post-title">' . esc_html( $title ) . '</div>';
$output.= '<ul class="' . esc_attr( $column_css ) . '">';
while ($query->have_posts()) {
$query->the_post();
$output.= '<li><div class="similar-post-holder">';
$output.= '<a class="mk-similiar-thumbnail" href="' . esc_url( get_permalink() ) . '" title="' . the_title_attribute(array('echo' => false)) . '">';
if ( class_exists( 'Jupiter_Donut' ) ) {
$image_src = Mk_Image_Resize::resize_by_id_adaptive( get_post_thumbnail_id(), 'crop', $width, $height, $crop = true, $dummy = true);
$output.= '<img src="' . $image_src['dummy'] . '" ' . $image_src['data-set'] . ' alt="' . the_title_attribute(array('echo' => false)) . '" />';
}
$output.= '<div class="image-hover-overlay"></div></a>';
$output.= '' . get_the_title() . '';
$output.= '</div></li>';
}
$output.= '</ul>';
$output.= '<div class="clearboth"></div></section>';
echo $output;
}
}
if ($tags) {
$tagcount = count($tags);
for ($i = 0; $i < $tagcount; $i++) {
$tagIDs[$i] = $tags[$i]->term_id;
}
$related = new WP_Query(array(
'tag__in' => $tagIDs,
'post__not_in' => array(
$post->ID
) ,
'showposts' => $showposts,
'ignore_sticky_posts' => 1
));
$output = '';
if ($related->have_posts()) {
$related_post_found = true;
mk_similar_posts_html( esc_html__( 'Recommended Posts', 'mk_framework' ) , $width, $height, $column_css, $related);
}
$post = $backup;
}
if (!$related_post_found) {
$recent = new WP_Query(array(
'showposts' => $showposts,
'nopaging' => 0,
'post__not_in' => array(
$post->ID
),
'post_status' => 'publish',
'ignore_sticky_posts' => 1
));
$output = '';
if ($recent->have_posts()) {
$related_post_found = true;
mk_similar_posts_html( esc_html__( 'Recent Posts', 'mk_framework' ) , $width, $height, $column_css, $recent );
}
}
wp_reset_postdata();
echo $output;
endif;
Related
so I wanted to know how, if at all, you could wrap every <li> tag of a wordpress submenu, under a <div> tag, such that the output looks something like this:
<ul class="menu">
<ul class="sub-menu ">
<div class="something"><li class="menu-item"></li></div>
<div class="something"><li class="menu-item"></li></div>
</ul>
</ul>
I'm new to wordpress so I don't know much about it, I've tried using a Walker but that just wraps around the <ul> tag, whereas I want to wrap every single <li> tag, I don't even know if it's possible, so feel free to let me know.
I hope this will help, my working walker with bootstrap 5:
class My_Walker_Menu extends Walker_Nav_Menu {
private $curr_item = null;
private $count = 0;
public function start_lvl( &$output, $depth = 0, $args = NULL ) {
$indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' );
$display_depth = ( $depth + 1);
$is_parent = get_post_meta( $this->curr_item->db_id, '_featured_menu_meta', true );
$is_parent = rest_sanitize_boolean( $is_parent );
$menu_parents = get_option('featured_menu_parents', []);
$is_featured = in_array( $this->curr_item->menu_item_parent, $menu_parents);
$class_names = ( $display_depth >= 1 ? 'dropdown-menu' : '' );
$class_names = ($is_parent || $is_featured) && $display_depth == 1 ? 'list-unstyled mb-0' : $class_names;
$output .= "\n" . $indent . '<ul class="' . $class_names . '">' . "\n";
}
public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) {
global $wp_query;
$this->curr_item = $data_object;
$item = $data_object;
$indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' );
$has_children = $args->walker->has_children;
$is_parent = get_post_meta( $item->db_id, '_featured_menu_meta', true );
$is_parent = rest_sanitize_boolean( $is_parent );
$menu_parents = get_option('featured_menu_parents', []);
$is_featured = in_array($item->menu_item_parent, $menu_parents);
// menu_item_parent
if ( $depth == 0 ) {
$item_class = $has_children ? 'nav-item dropdown' : 'nav-item';
}
if ( $depth >= 1 ) {
$item_class = $has_children ? 'dropdown' : '';
}
$item_attr = $item_class ? ' class="'. $item_class . '"' : '';
$output .= $indent . '<li'. $item_attr . '>';
// link attributes
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$attributes .= $has_children && $depth == 0 ? ' data-bs-toggle="dropdown"' : '';
if( $item->current ) {
$attr_classes = ' class="nav-link active' . ( $has_children ? ' dropdown-toggle' : '' ) . '"';
} else {
$attr_classes = ' class="nav-link'. ( $has_children ? ' dropdown-toggle' : '' ) . '"';
}
if ( $is_parent && $depth == 0 ) {
$args->after = '<div class="dropdown-menu overflow-hidden p-0" data-bs-popper="static">';
$args->after .= '<div class="d-lg-flex">';
$args->after .= '<div class="mega-dropdown-column pt-1 pt-lg-3 pb-lg-4">';
}
if ( $is_featured && $depth == 1 ) {
$thumb_url = get_the_post_thumbnail_url( $item->object_id, 'post-thumbnail' );
$thumb_url = trim($thumb_url);
$visibile = $this->count == 1 ? ' rounded-3 rounded-start-0' : ' zindex-2 opacity-0';
if( $thumb_url ) {
$args->after = '<span class="mega-dropdown-column position-absolute top-0 end-0 h-100 bg-size-cover bg-repeat-0'.$visibile.'" style="background-image: url('.$thumb_url .');">';
}
$attr_classes = ' class="dropdown-item"';
}
$attributes .= $attr_classes;
$item_output = sprintf( '%1$s<a%2$s>%3$s%4$s%5$s</a>%6$s',
$args->before,
$attributes,
$args->link_before,
apply_filters( 'the_title', $item->title, $item->ID ),
$args->link_after,
$args->after
);
$args->after = '';
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
$this->count++;
}
public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {
$item = $data_object;
$is_parent = get_post_meta( $item->db_id, '_featured_menu_meta', true );
$is_parent = rest_sanitize_boolean( $is_parent );
$menu_parents = get_option('featured_menu_parents', []);
$is_featured = in_array($item->menu_item_parent, $menu_parents);
if ( $is_parent && 0 == $depth ) {
$output .= '</div>';
$output .= ' <div class="mega-dropdown-column position-relative border-start zindex-3"></div>';
$output .= '</div>';
$output .= '</div>';
}
if ( $is_featured && $depth == 1 ) {
$thumb_url = get_the_post_thumbnail_url( $item->object_id, 'post-thumbnail' );
$thumb_url = trim($thumb_url);
if( $thumb_url ) {
$output .= '</span>';
}
}
$output .= "</li>\n";
}
}
wp_nav_menu([
'theme_location' => 'header_menu',
'container' => 'nav',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'navbarNav',
'menu_class' => 'navbar-nav navbar-nav-scroll me-auto',
'items_wrap' => '<ul class="%2$s">%3$s</ul>',
'depth' => 3,
'walker' => new My_Walker_Menu()
]);
What is the best approach for a shortcode to get its output from another function. echo works but it generate the shortcode before all content. before ending file there is a php switch that I am loading different functions in base of which style selected. This is the function:
staticMarkup($titleRendered, $contentRendered, $feedbackRendered, $roleRendered, $companyRendered, $image_urlRendered, $slider, $color);
<?php
add_shortcode('sample', 'sample_shortcode');
function sample_shortcode($atts)
{
global $tesio;
$markup = '';
// Attributes
$atts = shortcode_atts(array(
'style' => '',
'testio_id' => '',
'slider' => '',
'colors' => '',
'color' => '',
'wide' => 'no',
'bgcolor' => '',
'dpadding' => '',
'tpadding' => '',
'spadding' => '',
'instance' => 1
) , $atts);
wp_enqueue_script('testio-front-js');
wp_localize_script('testio-front-js', 'testio_var', $atts);
$testio_id = $explodeID = $style = $slider = $colors = $bgcolor = $vpadding = $color = $wide = $colorContrast = '';
$testio_id = $atts['testio_id'];
$explodeID = explode(',', $testio_id);
$style = $atts['style'];
$slider = $atts['slider'];
$colors = $atts['colors'];
$bgcolor = $atts['bgcolor'];
$dpadding = $atts['dpadding'];
$tpadding = $atts['tpadding'];
$spadding = $atts['spadding'];
$color = $atts['color'];
$wide = $atts['wide'];
$testioAmount = count(explode(',', $testio_id));
if (!empty($colors))
{
$colors = explode(',', $colors);
}
if (!empty($bgcolor))
{
$colorContrast = getContrast50($bgcolor);
}
static $uniqueID;
if ($testio_id !== '')
{
if ($testio_id == 'all')
{
$args = array(
'post_type' => 'testio_wp',
'post_status' => 'publish',
'posts_per_page' => - 1
);
}
else
if ($testioAmount > 1)
{
$args = array(
'post_type' => 'testio_wp',
'post_status' => 'publish',
'post__in' => $explodeID,
'posts_per_page' => $testioAmount,
'orderby' => 'post__in'
);
}
else
if ($testioAmount == 1)
{
$args = array(
'post_type' => 'testio_wp',
'post_status' => 'publish',
'p' => $testio_id,
'posts_per_page' => 1
);
}
$posts = get_posts($args);
$wrapperClass = 'staticWrap';
$wideClass = '';
$sliderClass = '';
$masonryContainer = '';
$masonryContainerClose = '';
$backgroundStyle = '';
$sliderMarkup = '';
$sliderCloseMarkup = '';
$wrapperClassExtra = '';
$dataAttr = 'data-padding = ' . $dpadding . ',' . $tpadding . ',' . $spadding;
switch ($style)
{
case 'static':
if ($wide == 'yes')
{
$wideClass = ' wide';
}
default:
break;
}
if ($testioAmount == 1)
{
$slider == 'no';
$sliderContainer = '';
}
$markup.= '<div class="testioWrap ' . $wrapperClass . $wrapperClassExtra . '" ' . $backgroundStyle . ' data-id="' . $wrapperClass . $uniqueID . '" ' . $dataAttr . '>';
$markup.= $sliderMarkup;
$markup.= $masonryContainer;
$x = 0;
$colorClass = '';
$postCount = '';
foreach($posts as $post)
{
$titleRendered = $post->post_title;
$contentRendered = $post->post_content;
$idRendered = $post->ID;
$feedbackRendered = get_field('testio_rate', $idRendered);
$roleRendered = get_field('testio_role', $idRendered);
$companyRendered = get_field('testio_company', $idRendered);
$image_urlRendered = get_the_post_thumbnail($idRendered, 'thumbnail');
if (!empty($colors))
{
$colorClass = $colors[$x % 5];
}
$x++;
$postCount++;
$freeMessage = '<div class="testio-notice"> Please get the pro version to unlock ' . $style . ' style Upgrade</div>';
switch ($style)
{
case "static":
staticMarkup($titleRendered, $contentRendered, $feedbackRendered, $roleRendered, $companyRendered, $image_urlRendered, $slider, $color);
default:
break;
}
}
$markup.= $masonryContainerClose;
$markup.= $sliderCloseMarkup;
$markup.= '</div>';
return $markup;
}
else
{
$markup.= '<div class="testio">';
$markup.= __('Please put an id to the shortcode', 'testio-wp');
$markup.= '</div>';
}
$uniqueID++;
}
?>
This is the codes inside the staticMarkup function:
<?php
function staticMarkup($title, $content, $feedback, $role, $company, $image_url, $slider, $color){
$markup ='';
$colorStyle = 'style="color: '.$color.';"';
if($slider == 'yes'){
$markup .= '<div>';
}
$markup .= '<div class="testio testioStatic" data-color="'.$color.'">';
$markup .= '<div class="leftBorder"></div>';
if($image_url !== '' ){
$markup .= '<div class="thumbnailWrapper">';
$markup .= $image_url;
$markup .= '</div>';
}
$markup .= feedbackMarkup($feedback);
$markup .= '<div class="testio-content">';
$markup .= '<p>'.$content.'</p>';
$markup .= '</div>';
$markup .= '<h3 class="testio-name" '.$colorStyle.'>~ ' .$title. '</h3>';
$markup .= '<h4 class="testio-role">' .$role. ' <span class="role-divider icon-at-sign"></span> ' .$company. '</h4>';
$markup .= '</div>';
if($slider == 'yes'){
$markup .= '</div>';
}
echo $markup;
}
?>
Within the staticMarkup function replace:
echo $markup;
with:
return $markup;
This will return the variable where it has been positioned/called as opposed to above all content.
I try to get the url thumbnail of my custom post type but that's don't work, can I have some help please.
My var is $image_url.
The href is empty
Here my loop :
<?php $loop = new WP_Query( array( 'post_type' => 'partenaires', 'post_status' => 'publish', 'order' => 'ASC'));
$i = 0;
$partners_name = get_field('partners_name');
$col1 = $col2 = $col3 = '';
while ( $loop->have_posts() ) : $loop->the_post();
$id = get_the_ID();
$image = wp_get_attachment_image_src($post_id);
$image_url = $image[0];
$article = '<a href="'. get_permalink() .'" class="partnership__canva">';
$article .= '<div class="partnership__visual" style="background-image: url("'. $image_url .'");"></div>';
$article .= '<div class="partnership__text">';
$article .= '<p class="partnership__name">'. get_post_meta($id, 'partners_name', true) .'</p>';
$article .= '<h3 class="artnership__company">'. get_the_title() .'</h3>';
$article .= '</div>';
$article .= '</a>';
switch($i % 3) {
case 0:
$col1 .= $article;
break;
case 1:
$col2 .= $article;
break;
case 2:
$col3 .= $article;
break;
default:
break;
}
$i++;
endwhile; wp_reset_query(); ?>
Use get_the_post_thumbnail_url( $post, $size ) instead of
$image = wp_get_attachment_image_src($post_id);
$image_url = $image[0];
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/
I have been building a website recently and I faced a problem with the pagination. I am getting same posts (portfolio post in this case) on each page. I've been googling around how to solve this but it seems that this problem is individual on each theme.
This is the code from the page template I'm using...
<?php if ( have_posts() ) while ( have_posts() ) : the_post();
$pag = get_post_meta( $post->ID, 'folio_pag', true );
$per = get_post_meta( $post->ID, 'folio_per', true );
$style = get_post_meta( $post->ID, 'folio_style', true );
$animation = get_post_meta( $post->ID, 'folio_anim', true );
$color = get_post_meta( $post->ID, 'folio_color', true );
$info = get_post_meta( $post->ID, 'folio_info', true );
$ratio = get_post_meta( $post->ID, 'folio_ratio', true );
$r = explode( ':', $ratio );
$cols = get_post_meta( $post->ID, 'folio_cols', true );
$c = $cols == 'two' ? 648 : ( $cols == 'three' ? 432 : 324 );
$img_factor = '0';
$cats = get_post_meta( $post->ID, 'folio_cats', true );
$query_filter = '';
$filter_output = '<li>' . __( 'All', 'krown' ) . '</li>';
$show_cats = get_post_meta( $post->ID, 'folio_filter', true ) == 'enable-filters' ? true : false;
if ( ! empty ( $cats ) ) {
if ( sizeof( $cats ) == 1 ) {
$show_cats = false;
}
foreach ( $cats as $cat ) {
$filter = get_term_by( 'id', $cat, 'portfolio_category' );
$query_filter .= $filter->slug . ', ';
$filter_output .= '<li>' . $filter->name . '</li>';
}
} else {
$cats = get_categories( array( 'taxonomy'=>'portfolio_category' ) );
foreach ( $cats as $cat ) {
$filter_output .= '<li>' . $cat->name . '</li>';
}
}
?>
<?php if ( get_post_meta( $post->ID, 'folio_content', true ) == 'content-above' ) {
the_content();
} ?>
<?php if ( $show_cats ) {
echo '<div id="filter"><ul class="clearfix">' . $filter_output . '</ul></div>';
} ?>
<div id="portfolio-holder" class="clearfix">
<ul id="portfolio" class="folio-grid cols-<?php echo $cols; ?> style-<?php echo $animation . ' ' . $color; ?> show-<?php echo $info; ?> layout-<?php echo $style; ?> clearfix">
<?php
$paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : ( get_query_var( 'page' ) ? get_query_var( 'page' ) : 1 );
$args = array(
'post_type' => 'portfolio',
'portfolio_category' => $query_filter,
'offset' => 0,
'posts_per_page' => ( $pag == 'no-pagination' ? -1 : $per ),
'paged' => $paged
);
$all_posts = new WP_Query( $args );
$page_id = $post->ID;
while ( $all_posts->have_posts() ) : $all_posts->the_post();
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_image_src( $thumb, 'full' );
if ( $thumb == '' ) {
$img_url = Array( get_template_directory_uri() . '/images/blank_2.gif' );
}
$retina = krown_retina();
$retina_thumb = get_post_meta( $post->ID, 'portfolio_retina-thumbnail_thumbnail_id', true );
if ( $style == 'fixed' ) {
switch ( $cols ) {
case 'two':
$img_width = 648;
$img_height = ceil( $img_width / $r[0] * $r[1] );
break;
case 'three':
$img_width = 432;
$img_height = ceil( $img_width / $r[0] * $r[1] );
break;
default:
$img_width = 324;
$img_height = ceil( $img_width / $r[0] * $r[1] );
break;
}
if ( $retina === 'true' && $retina_thumb != '' ) {
$retina_url = wp_get_attachment_image_src( $retina_thumb, 'full' );
$image = aq_resize( $retina_url[0], $img_width*2, $img_height*2, true, false );
} else {
$image = aq_resize( $img_url[0], $img_width, $img_height, true, false );
}
} else if ( $style == 'masonry' ) {
$img_factor = 1;
$img_width = $c;
if ( $retina === 'true' && $retina_thumb != '' ) {
$retina_url = wp_get_attachment_image_src( $retina_thumb, 'full' );
$image = aq_resize( $retina_url[0], $img_width*2, null, false, false );
} else {
$image = aq_resize( $img_url[0], $img_width, null, false, false );
}
} else if ( $style == 'masonry-advanced' ) {
$img_factor = floor( $img_url[1] / $c );
$img_width = $img_factor * $c;
if ( $retina === 'true' && $retina_thumb != '' ) {
$retina_url = wp_get_attachment_image_src( $retina_thumb, 'full' );
$image = aq_resize( $retina_url[0], $img_width*2, null, false, false );
} else {
$image = aq_resize( $img_url[0], $img_width, null, false, false );
}
}
?>
<li class="item <?php krown_categories( $post->ID, 'portfolio_category', ' ', 'slug' ); ?>" data-factor="<?php echo $img_factor; ?>">
<a href="<?php echo get_new_permalink( $page_id, $post->ID, $cats ); ?>">
<img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" alt="<?php the_title(); ?>" />
<div class="caption">
<div>
<div>
<h3><?php the_title(); ?></h3>
<span class="category"><?php krown_categories( $post->ID, 'portfolio_category' ); ?></span>
<span class="excerpt"><?php echo krown_excerpt( 'krown_excerptlength_post' ); ?></span>
</div>
</div>
</div>
</a>
</li>
<?php endwhile;
?>
</ul>
</div>
<?php if ( $pag == 'classic' ) {
krown_pagination( $all_posts, true );
} else if ( $pag == 'infinte-loading' ) {
echo '<div class="infinite-barrier"><span class="preloader"></span><p class="end">' . __( 'No More Projects', 'krown' ) . '</p><a id="infinite-link" href="' . next_posts( 0, false ) . '">' . __( 'Load More Projects', 'krown' ) . '</a></div>';
} ?>
<?php wp_reset_query(); ?>
<?php if ( get_post_meta( $post->ID, 'folio_content', true ) == 'content-below' ) {
the_content();
} ?>
I think the reason why the same content is showing in every other pages because you set offset to 0 in the portfolio query. You should update your offset $offset = $per * ($paged-1) so that every page change would tell WP_Query to offset right amount of posts that match current page context.
Hi to all I have a funtion to create a numeric pagination for blog posts:
function fb_paging_bar( $args = array() ) {
$defaults = array(
'range' => 4,
'custom_query' => FALSE,
'previous_string' => __( 'PREVIOUS', 'themename' ),
'next_string' => __( 'NEXT PAGE', 'themename' ),
'view_fp' => TRUE,
'view_lp' => TRUE,
'before_output' => '<div class="paginator" id="movie_paginator">',
'after_output' => '</div>'
);
$args = wp_parse_args(
$args,
apply_filters( 'fb_paging_bar_defaults', $defaults )
);
$args['range'] = (int) $args['range'] - 1;
if ( !$args['custom_query'] )
$args['custom_query'] = #$GLOBALS['wp_query'];
$count = (int) $args['custom_query']->max_num_pages;
$page = intval( get_query_var( 'paged' ) );
$ceil = ceil( $args['range'] / 2 );
if ( $count <= 1 )
return FALSE;
if ( !$page )
$page = 1;
if ( $count > $args['range'] ) {
if ( $page <= $args['range'] ) {
$min = 1;
$max = $args['range'] + 1;
} elseif ( $page >= ($count - $ceil) ) {
$min = $count - $args['range'];
$max = $count;
} elseif ( $page >= $args['range'] && $page < ($count - $ceil) ) {
$min = $page - $ceil;
$max = $page + $ceil;
}
} else {
$min = 1;
$max = $count;
}
$echo = '';
$previous = intval($page) - 1;
$previous = esc_attr( get_pagenum_link($previous) );
if ( $previous && (1 != $page) )
$echo .= '<a class="page page-prev" href="' . $previous . '" title="' . __( 'PREVIOUS', 'themename' ) . '">' . $args['previous_string'] . '</a>';
$firstpage = esc_attr( get_pagenum_link(1) );
if ( $args['view_fp'] && $firstpage && (1 != $page) )
$echo .= '<a class="page" href="' . $firstpage . '">' . __( '1', 'themename' ) . '</a>';
if ( !empty($min) && !empty($max) ) {
for( $i = $min; $i <= $max; $i++ ) {
if ($page == $i) {
$echo .= '<span class="page page-mobile disabled">' . str_pad( (int)$i, 1, '0', STR_PAD_LEFT ) . '</span>';
} else {
$echo .= sprintf( '%002d', esc_attr( get_pagenum_link($i) ), $i );
}
}
}
if ($args['view_lp']) {
$lastpage = esc_attr( get_pagenum_link($count) );
if ( $lastpage && ($count != $page) ) {
$count = str_pad( (int)$count, 2, '0', STR_PAD_LEFT );
$echo .= '<span class="page no-page page-mobile disabled">...</span><a class="page" href="' . $lastpage . '">' . $count . '</a>';
}
}
$next = intval($page) + 1;
$next = esc_attr( get_pagenum_link($next) );
if ($next && ($count != $page) )
$echo .= '<a class="page page-next" href="' . $next . '" title="' . __( 'NEXT PAGE', 'themename') . '">' . $args['next_string'] . '</a>';
if ( isset($echo) )
echo $args['before_output'] . $echo . $args['after_output'];
}
The result of this code above is like the first image
But Im trying to find the right way to add more numers because as u see this one shows only first,current and last number
is there any way to make it with more numbers like the second screenshot?